类 Logger::Formatter
日志消息的默认格式化器。
常量
- DatetimeFormat
- Format
属性
datetime_format[RW]
公共类方法
new() 点击切换源代码
# File lib/logger/formatter.rb, line 11 def initialize @datetime_format = nil end
公共实例方法
call(severity, time, progname, msg) 点击切换源代码
# 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
私有实例方法
format_datetime(time) 点击切换源代码
# File lib/logger/formatter.rb, line 21 def format_datetime(time) time.strftime(@datetime_format || DatetimeFormat) end
msg2str(msg) 点击切换源代码
# 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