Class: Epilog::Formatter
- Inherits:
-
Object
- Object
- Epilog::Formatter
- Defined in:
- lib/epilog/log_formatter.rb
Constant Summary collapse
- SEVERITY_MAP =
{ 'FATAL' => 'ALERT', 'WARN' => 'WARNING' }.freeze
- DEFAULT_TIME_FORMAT =
'%Y-%m-%dT%H:%M:%S%z'
Instance Attribute Summary collapse
- #datetime_format ⇒ Object
-
#filter ⇒ Object
readonly
Returns the value of attribute filter.
Instance Method Summary collapse
- #call(severity, time, progname, msg) ⇒ Object
-
#initialize(options = {}) ⇒ Formatter
constructor
A new instance of Formatter.
Constructor Details
Instance Attribute Details
#datetime_format ⇒ Object
31 32 33 |
# File 'lib/epilog/log_formatter.rb', line 31 def datetime_format @datetime_format || DEFAULT_TIME_FORMAT end |
#filter ⇒ Object (readonly)
Returns the value of attribute filter.
12 13 14 |
# File 'lib/epilog/log_formatter.rb', line 12 def filter @filter end |
Instance Method Details
#call(severity, time, progname, msg) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/epilog/log_formatter.rb', line 19 def call(severity, time, progname, msg) log = base_log(severity, time, progname) log.merge!((msg)) if log[:exception].is_a?(Exception) log[:exception] = format_error(log[:exception]) end log = before_write(log) "#{JSON.dump(log)}\n" end |