Class: SemanticLogger::Formatters::Json

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

Instance Attribute Summary

Attributes inherited from Raw

#hash, #log, #logger, #time_key

Attributes inherited from Base

#filter, #name

Instance Method Summary collapse

Methods inherited from Raw

#application, #duration, #exception, #host, #level, #message, #metric, #name, #named_tags, #payload, #process_info, #tags, #time

Methods inherited from Base

#backtrace, #fast_tag, #level, #level=, #log, #measure, #payload, #pop_tags, #push_tags, #should_log?, #silence, #tagged, #tags, #with_payload

Constructor Details

#initialize(time_format: :iso_8601, log_host: true, log_application: true, time_key: :timestamp) ⇒ 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, log_host: true, log_application: true, time_key: :timestamp)
  super(time_format: time_format, log_host: log_host, log_application: log_application, time_key: time_key)
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