Class Ohai::Log::Formatter
In: lib/ohai/log/formatter.rb
Parent: Logger::Formatter
Config System RuntimeError Exec Log\n[lib/ohai/log.rb\nlib/ohai/log/formatter.rb] lib/ohai/log/formatter.rb lib/ohai/config.rb lib/ohai/system.rb Command FromFile Mixin lib/ohai/exception.rb Exceptions Ohai dot/m_71_0.png

Methods

call   msg2str   show_time=  

Public Class methods

[Source]

    # File lib/ohai/log/formatter.rb, line 27
27:       def self.show_time=(show=false)
28:         @@show_time = show
29:       end

Public Instance methods

Prints a log message as ’[time] severity: message’ if Ohai::Log::Formatter.show_time == true. Otherwise, doesn‘t print the time.

[Source]

    # File lib/ohai/log/formatter.rb, line 33
33:       def call(severity, time, progname, msg)
34:         if @@show_time
35:           sprintf("[%s] %s: %s\n", time.rfc2822(), severity, msg2str(msg))
36:         else
37:           sprintf("%s: %s\n", severity, msg2str(msg))
38:         end
39:       end

Converts some argument to a Logger.severity() call to a string. Regular strings pass through like normal, Exceptions get formatted as "message (class)\nbacktrace", and other random stuff gets put through "object.inspect"

[Source]

    # File lib/ohai/log/formatter.rb, line 44
44:       def msg2str(msg)
45:         case msg
46:         when ::String
47:           msg
48:         when ::Exception
49:           "#{ msg.message } (#{ msg.class })\n" <<
50:             (msg.backtrace || []).join("\n")
51:         else
52:           msg.inspect
53:         end
54:       end

[Validate]