類別 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