Class: SemanticLogger::Formatters::Fluentd

Inherits:
Json
  • Object
show all
Defined in:
lib/semantic_logger/formatters/fluentd.rb

Overview

Fluentd is similar to SemanticLogger::Formatters::Json but with log levels that are recognized by kubernetes fluentd.

Instance Attribute Summary collapse

Attributes inherited from Raw

#hash, #time_key

Attributes inherited from Base

#filter, #name

Instance Method Summary collapse

Methods inherited from Json

#call

Methods inherited from Raw

#application, #call, #duration, #environment, #exception, #file_name_and_line, #host, #message, #metric, #name, #named_tags, #payload, #pid, #tags, #thread_name, #time

Methods inherited from Base

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

Constructor Details

#initialize(time_format: :rfc_3339, time_key: :time, need_process_info: false, **args) ⇒ Fluentd

Returns a new instance of Fluentd.



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

def initialize(time_format: :rfc_3339, time_key: :time, need_process_info: false, **args)
  @need_process_info = need_process_info
  super(time_format: time_format, time_key: time_key, **args)
end

Instance Attribute Details

#need_process_infoObject (readonly)

Returns the value of attribute need_process_info.



8
9
10
# File 'lib/semantic_logger/formatters/fluentd.rb', line 8

def need_process_info
  @need_process_info
end

Instance Method Details

#levelObject



15
16
17
18
# File 'lib/semantic_logger/formatters/fluentd.rb', line 15

def level
  hash["severity"]       = log.level
  hash["severity_index"] = log.level_index
end

#process_infoObject



20
21
22
23
# File 'lib/semantic_logger/formatters/fluentd.rb', line 20

def process_info
  # Ignore fields: pid, thread, file and line by default
  super() if need_process_info
end