Class: SemanticLogger::Formatters::Fluentd
- 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
-
#need_process_info ⇒ Object
readonly
Returns the value of attribute need_process_info.
Attributes inherited from Raw
Attributes inherited from Base
#filter, #instance_named_tags, #instance_tags, #name
Instance Method Summary collapse
- #file_name_and_line ⇒ Object
-
#initialize(time_format: :rfc_3339, time_key: :time, need_process_info: false, log_host: false, **args) ⇒ Fluentd
constructor
A new instance of Fluentd.
- #level ⇒ Object
-
#pid ⇒ Object
Ignore process fields: pid, thread, file and line by default.
- #thread_name ⇒ Object
Methods inherited from Json
Methods inherited from Raw
#application, #call, #duration, #environment, #exception, #host, #message, #metric, #name, #named_tags, #payload, #tags, #time
Methods inherited from Base
#backtrace, #fast_tag, #level=, #log, #measure, #named_tags, #pop_tags, #push_tags, #should_log?, #silence, #tagged, #tags, #with_level
Constructor Details
#initialize(time_format: :rfc_3339, time_key: :time, need_process_info: false, log_host: 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, log_host: false, **args) @need_process_info = need_process_info super(time_format: time_format, time_key: time_key, log_host: log_host, **args) end |
Instance Attribute Details
#need_process_info ⇒ Object (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
#file_name_and_line ⇒ Object
32 33 34 |
# File 'lib/semantic_logger/formatters/fluentd.rb', line 32 def file_name_and_line super if need_process_info end |
#level ⇒ Object
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 |
#pid ⇒ Object
Ignore process fields: pid, thread, file and line by default.
These are rarely useful under Fluentd (e.g. containerized processes
usually have pid 1), so they are only included when explicitly requested
via need_process_info: true.
24 25 26 |
# File 'lib/semantic_logger/formatters/fluentd.rb', line 24 def pid super if need_process_info end |
#thread_name ⇒ Object
28 29 30 |
# File 'lib/semantic_logger/formatters/fluentd.rb', line 28 def thread_name super if need_process_info end |