Logger::Formatter
class Logger::Formatter
Parent:Object
日志消息的默认格式化程序。
常量
格式
属性
datetime_formatRW
公共类方法
new() Show source
# File lib/logger.rb, line 591
def initialize
@datetime_format = nil
end
公共实例方法
call(severity, time, progname, msg) Show source
# File lib/logger.rb, line 595
def call(severity, time, progname, msg)
Format % [severity[0..0], format_datetime(time), $$, severity, progname,
msg2str(msg)]
end
私有实例方法
format_datetime(time) Show source
# File lib/logger.rb, line 602
def format_datetime(time)
time.strftime(@datetime_format || "%Y-%m-%dT%H:%M:%S.%6N ".freeze)
end
msg2str(msg) Show source
# File lib/logger.rb, line 606
def msg2str(msg)
case msg
when ::String
msg
when ::Exception
"#{ msg.message } (#{ msg.class })\n" <<
(msg.backtrace || []).join("\n")
else
msg.inspect
end
end