Class: LoggerExtension::Formatter

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

Constant Summary collapse

Format =
"\n#{ '#' * 143 }\n[%s], [%s] %5s:\n %s\n#{ '#' * 143 }\n"
DEFAULT_FORMAT =
'%Y-%m-%d %H:%M:%S'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(datetime_format = nil) ⇒ Formatter

Returns a new instance of Formatter.



8
9
10
# File 'lib/logger_extension/formatter.rb', line 8

def initialize(datetime_format = nil)
  @datetime_format = datetime_format || DEFAULT_FORMAT
end

Instance Attribute Details

#datetime_formatObject

Returns the value of attribute datetime_format.



6
7
8
# File 'lib/logger_extension/formatter.rb', line 6

def datetime_format
  @datetime_format
end

Instance Method Details

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



12
13
14
# File 'lib/logger_extension/formatter.rb', line 12

def call(severity, time, progname, msg)
  Format % [progname, format_datetime(time), severity, msg2str(msg)]
end