class Logger::Formatter
Default formatter for log messages.
Constants
- Format
Attributes
datetime_format[RW]
Public Class Methods
# File lib/logger.rb, line 556 def initialize @datetime_format = nil end
Public Instance Methods
# File lib/logger.rb, line 560 def call(severity, time, progname, msg) Format % [severity[0..0], format_datetime(time), $$, severity, progname, msg2str(msg)] end
Private Instance Methods
# File lib/logger.rb, line 567 def format_datetime(time) time.strftime(@datetime_format || "%Y-%m-%dT%H:%M:%S.%6N ".freeze) end
# File lib/logger.rb, line 571 def msg2str(msg) case msg when ::String msg when ::Exception "#{ msg.message } (#{ msg.class })\n" << (msg.backtrace || []).join("\n") else msg.inspect end end
Ruby Core © 1993–2017 Yukihiro Matsumoto
Licensed under the Ruby License.
Ruby Standard Library © contributors
Licensed under their own licenses.