Sha256: 599489d3b4ece4c102dd84b05745b05532e86a6870011ca8cef175e4f99e6976

Contents?: true

Size: 611 Bytes

Versions: 6

Compression:

Stored size: 611 Bytes

Contents

# frozen_string_literal: true

require 'lograge'
require 'active_support/core_ext/array'

module Loggable
  module Lograge
    # Custom formatter class that renders logs as ruby objects with just the ecs fields generated by the logger, the
    # message, and a lograge flag so the ECS logger knows to process this further before rendering
    class Formatter < ::Lograge::Formatters::KeyValue
      def call(data)
        (data[:ecs] || {}).merge(message: super(data), lograge: true)
      end

      protected

      def fields_to_display(data)
        data.keys.excluding(%i[ecs])
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
researchable_loggable-1.3.1 lib/loggable/lograge/formatter.rb
researchable_loggable-1.3.0 lib/loggable/lograge/formatter.rb
researchable_loggable-1.2.0 lib/loggable/lograge/formatter.rb
researchable_loggable-1.1.0 lib/loggable/lograge/formatter.rb
researchable_loggable-1.0.2 lib/loggable/lograge/formatter.rb
researchable_loggable-1.0.1 lib/loggable/lograge/formatter.rb