Class: Dry::Logger::Formatters::JSON
- Inherits:
-
Structured
- Object
- Logger::Formatter
- Structured
- Dry::Logger::Formatters::JSON
- Defined in:
- lib/dry/logger/formatters/json.rb
Overview
JSON formatter.
This formatter returns log entries in JSON format.
Constant Summary
Constants inherited from Structured
Structured::DEFAULT_FILTERS, Structured::NOOP_FILTER
Instance Attribute Summary
Attributes inherited from Structured
Instance Method Summary collapse
- #format(entry) ⇒ Object private
- #format_exception(value) ⇒ Object private
- #format_severity(value) ⇒ Object private
- #format_time(value) ⇒ Object private
Methods inherited from Structured
#call, #format_values, #initialize
Constructor Details
This class inherits a constructor from Dry::Logger::Formatters::Structured
Instance Method Details
#format(entry) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
20 21 22 23 24 |
# File 'lib/dry/logger/formatters/json.rb', line 20 def format(entry) hash = format_values(entry).compact hash.update(hash.delete(:exception)) if entry.exception? ::JSON.dump(hash) end |
#format_exception(value) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
34 35 36 37 38 39 40 |
# File 'lib/dry/logger/formatters/json.rb', line 34 def format_exception(value) { exception: value.class, message: value., backtrace: value.backtrace || EMPTY_ARRAY } end |
#format_severity(value) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
28 29 30 |
# File 'lib/dry/logger/formatters/json.rb', line 28 def format_severity(value) value.upcase end |
#format_time(value) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
44 45 46 |
# File 'lib/dry/logger/formatters/json.rb', line 44 def format_time(value) value.getutc.iso8601 end |