Class: JsonLogging::Formatter
- Inherits:
-
Logger::Formatter
- Object
- Logger::Formatter
- JsonLogging::Formatter
- Defined in:
- lib/json_logging/formatter.rb
Instance Attribute Summary collapse
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
Instance Method Summary collapse
- #call(severity, timestamp, progname, msg) ⇒ Object
-
#initialize(tags: []) ⇒ Formatter
constructor
A new instance of Formatter.
Constructor Details
#initialize(tags: []) ⇒ Formatter
3 4 5 6 |
# File 'lib/json_logging/formatter.rb', line 3 def initialize(tags: []) super() = Array() end |
Instance Attribute Details
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
8 9 10 |
# File 'lib/json_logging/formatter.rb', line 8 def end |
Instance Method Details
#call(severity, timestamp, progname, msg) ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/json_logging/formatter.rb', line 10 def call(severity, , progname, msg) = Helpers.() payload = PayloadBuilder.build_base_payload(msg, severity: severity, timestamp: ) payload = PayloadBuilder.merge_context(payload, additional_context: JsonLogging.additional_context.compact, tags: ) "#{payload.compact.to_json}\n" rescue => e build_fallback_output(severity, , msg, e) end |