Sha256: ff7f9bd346d2766824d91ce7429b7d77eeec61e3f79e2cd4c24c11aa04cb46bc

Contents?: true

Size: 743 Bytes

Versions: 17

Compression:

Stored size: 743 Bytes

Contents

require "json"

module SemanticLogger
  module Formatters
    # 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(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

      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
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
semantic_logger-4.16.1 lib/semantic_logger/formatters/fluentd.rb
semantic_logger-4.16.0 lib/semantic_logger/formatters/fluentd.rb
semantic_logger-4.15.0 lib/semantic_logger/formatters/fluentd.rb
semantic_logger-4.14.0 lib/semantic_logger/formatters/fluentd.rb
semantic_logger-4.13.0 lib/semantic_logger/formatters/fluentd.rb
semantic_logger-4.12.0 lib/semantic_logger/formatters/fluentd.rb
semantic_logger-4.11.0 lib/semantic_logger/formatters/fluentd.rb
semantic_logger-4.10.0 lib/semantic_logger/formatters/fluentd.rb
semantic_logger-4.9.0 lib/semantic_logger/formatters/fluentd.rb
semantic_logger-4.8.2 lib/semantic_logger/formatters/fluentd.rb
semantic_logger-4.8.1 lib/semantic_logger/formatters/fluentd.rb
semantic_logger-4.8.0 lib/semantic_logger/formatters/fluentd.rb
semantic_logger-4.7.4 lib/semantic_logger/formatters/fluentd.rb
semantic_logger-4.7.3 lib/semantic_logger/formatters/fluentd.rb
semantic_logger-4.7.2 lib/semantic_logger/formatters/fluentd.rb
semantic_logger-4.7.1 lib/semantic_logger/formatters/fluentd.rb
semantic_logger-4.7.0 lib/semantic_logger/formatters/fluentd.rb