Class: SemanticLogger::Formatters::Fluentd
- Defined in:
- lib/semantic_logger/formatters/fluentd.rb
Overview
Fluentd is similar to SemanticLogger::Formatters::Json but with log level that are recongnized by kubernetes fluentd.
Instance Attribute Summary collapse
-
#need_process_info ⇒ Object
readonly
Returns the value of attribute need_process_info.
Attributes inherited from Raw
#hash, #log, #logger, #time_key
Attributes inherited from Base
Instance Method Summary collapse
- #call(log, logger) ⇒ Object
-
#initialize(log_host: true, log_application: true, need_process_info: false) ⇒ Fluentd
constructor
A new instance of Fluentd.
- #process_info ⇒ Object
- #severity ⇒ Object
Methods inherited from Raw
#application, #duration, #exception, #host, #level, #message, #metric, #name, #named_tags, #payload, #tags, #time
Methods inherited from Base
#backtrace, #fast_tag, #level, #level=, #log, #measure, #named_tags, #payload, #pop_tags, #push_tags, #should_log?, #silence, #tagged, #tags, #with_payload
Constructor Details
#initialize(log_host: true, log_application: true, need_process_info: false) ⇒ Fluentd
Returns a new instance of Fluentd.
10 11 12 13 |
# File 'lib/semantic_logger/formatters/fluentd.rb', line 10 def initialize(log_host: true, log_application: true, need_process_info: false) @need_process_info = need_process_info super(log_host: log_host, log_application: log_application, time_key: 'time', time_format: :rfc_3339) 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
#call(log, logger) ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/semantic_logger/formatters/fluentd.rb', line 25 def call(log, logger) self.hash = {} self.log = log self.logger = logger host; application; time; severity; process_info; duration; ; ; name; ; payload; exception; metric hash hash.to_json end |
#process_info ⇒ Object
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 |
#severity ⇒ Object
15 16 17 18 |
# File 'lib/semantic_logger/formatters/fluentd.rb', line 15 def severity hash['severity'] = log.level hash['severity_index'] = log.level_index end |