lib/semantic_logger/formatters/fluentd.rb in semantic_logger-4.5.0 vs lib/semantic_logger/formatters/fluentd.rb in semantic_logger-4.6.0.beta1

- old
+ new

@@ -1,37 +1,26 @@ require 'json' module SemanticLogger module Formatters - # Fluentd is similar to SemanticLogger::Formatters::Json but with log level that are recongnized + # Fluentd is similar to SemanticLogger::Formatters::Json but with log levels that are recognized # by kubernetes fluentd. class Fluentd < Json attr_reader :need_process_info - def initialize(log_host: true, log_application: true, need_process_info: false) + def initialize(time_format: :rfc_3339, time_key: :time, need_process_info: false, **args) @need_process_info = need_process_info - super(log_host: log_host, log_application: log_application, time_key: 'time', time_format: :rfc_3339) + super(time_format: time_format, time_key: time_key, **args) end - def severity - hash['severity'] = log.level + def level + hash['severity'] = log.level hash['severity_index'] = log.level_index end def process_info # Ignore fields: pid, thread, file and line by default super() if need_process_info - end - - def call(log, logger) - self.hash = {} - self.log = log - self.logger = logger - - host; application; time; severity; process_info; duration; tags; named_tags; name; message; payload; exception; metric - hash - - hash.to_json end end end end