Class: SemanticLogger::Formatters::Logfmt
- Defined in:
- lib/semantic_logger/formatters/logfmt.rb
Overview
Produces logfmt formatted messages
The following fields are extracted from the raw log and included in the formatted message:
:timestamp, :level, :name, :message, :duration, :tags, :named_tags
E.g.
="2020-07-20T08:32:05.375276Z" level=info name="DefaultTest" base="breakfast" spaces="second breakfast" double_quotes="\"elevensies\"" single_quotes="'lunch'" tag="success"
All timestamps are ISO8601 formatteed All user supplied values are escaped and surrounded by double quotes to avoid ambiguious message delimeters ‘tags` are treated as keys with boolean values. Tag names are not formatted or validated, ensure you use valid logfmt format for tag names. `named_tags` are flattened are merged into the top level message field. Any conflicting fields are overridden. `payload` values take precedence over `tags` and `named_tags`. Any conflicting fields are overridden.
Futher Reading brandur.org/logfmt
Instance Attribute Summary
Attributes inherited from Raw
Attributes inherited from Base
Instance Method Summary collapse
- #call(log, logger) ⇒ Object
-
#initialize(time_format: :iso_8601, time_key: :timestamp, **args) ⇒ Logfmt
constructor
A new instance of Logfmt.
Methods inherited from Raw
#application, #duration, #environment, #exception, #file_name_and_line, #host, #level, #message, #metric, #name, #named_tags, #payload, #pid, #tags, #thread_name, #time
Methods inherited from Base
#backtrace, #fast_tag, #level, #level=, #log, #measure, #named_tags, #pop_tags, #push_tags, #should_log?, #silence, #tagged, #tags
Constructor Details
#initialize(time_format: :iso_8601, time_key: :timestamp, **args) ⇒ Logfmt
21 22 23 |
# File 'lib/semantic_logger/formatters/logfmt.rb', line 21 def initialize(time_format: :iso_8601, time_key: :timestamp, **args) super(time_format: time_format, time_key: time_key, **args) end |
Instance Method Details
#call(log, logger) ⇒ Object
25 26 27 28 29 |
# File 'lib/semantic_logger/formatters/logfmt.rb', line 25 def call(log, logger) @raw = super(log, logger) raw_to_logfmt end |