Class: Epilog::Formatter
- Inherits:
-
Object
- Object
- Epilog::Formatter
- Includes:
- ContextFormatter
- 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.
Methods included from ContextFormatter
#context, #pop_context, #push_context
Constructor Details
#initialize(options = {}) ⇒ Formatter
Returns a new instance of Formatter.
17 18 19 |
# File 'lib/epilog/log_formatter.rb', line 17 def initialize( = {}) @filter = [:filter] || Filter::Blacklist.new end |
Instance Attribute Details
#datetime_format ⇒ Object
34 35 36 |
# File 'lib/epilog/log_formatter.rb', line 34 def datetime_format @datetime_format || DEFAULT_TIME_FORMAT end |
#filter ⇒ Object (readonly)
Returns the value of attribute filter.
14 15 16 |
# File 'lib/epilog/log_formatter.rb', line 14 def filter @filter end |
Instance Method Details
#call(severity, time, progname, msg) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/epilog/log_formatter.rb', line 21 def call(severity, time, progname, msg) log = base_log(severity, time, progname) log.merge!(context) 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 |