Class: Logger::Formatter

Inherits:
Object
  • Object
show all
Defined in:
lib/logger/formatter.rb

Overview

Default formatter for log messages.

Constant Summary collapse

Format =
"%.1s, [%s #%d] %5s -- %s: %s\n"
DatetimeFormat =
"%Y-%m-%dT%H:%M:%S.%6N"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeFormatter

Returns a new instance of Formatter.



11
12
13
# File 'lib/logger/formatter.rb', line 11

def initialize
  @datetime_format = nil
end

Instance Attribute Details

#datetime_formatObject

Returns the value of attribute datetime_format.



9
10
11
# File 'lib/logger/formatter.rb', line 9

def datetime_format
  @datetime_format
end

Instance Method Details

#call(severity, time, progname, msg) ⇒ Object



15
16
17
# 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