Class: SemanticLogger::Formatters::Json

Inherits:
Raw
  • Object
show all
Defined in:
lib/semantic_logger/formatters/json.rb

Direct Known Subclasses

Fluentd

Instance Attribute Summary

Attributes inherited from Raw

#hash, #time_key

Attributes inherited from Base

#filter, #name

Instance Method Summary collapse

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) ⇒ Json

Default JSON time format is ISO8601



6
7
8
# File 'lib/semantic_logger/formatters/json.rb', line 6

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

Returns log messages in JSON format



11
12
13
# File 'lib/semantic_logger/formatters/json.rb', line 11

def call(log, logger)
  super(log, logger).to_json
end