class Logger::Formatter
Default formatter for log messages.
Constants
- DatetimeFormat
- Format
Attributes
Public Class Methods
Public Instance Methods
Source
# File lib/logger/formatter.rb, line 15 def call(severity, time, progname, msg) sprintf(Format, severity, format_datetime(time), Process.pid, severity, progname, msg2str(msg)) end
Private Instance Methods
Source
# File lib/logger/formatter.rb, line 21 def format_datetime(time) time.strftime(@datetime_format || DatetimeFormat) end
Source
# File lib/logger/formatter.rb, line 25
def msg2str(msg)
case msg
when ::String
msg
when ::Exception
"#{ msg.message } (#{ msg.class })\n#{ msg.backtrace.join("\n") if msg.backtrace }"
else
msg.inspect
end
end
Ruby Core © 1993–2024 Yukihiro Matsumoto
Licensed under the Ruby License.
Ruby Standard Library © contributors
Licensed under their own licenses.