Sha256: bc322b062ea643e6bfd82635fc7635b8247e51067f9f9ede2752117014b0be23

Contents?: true

Size: 747 Bytes

Versions: 10

Compression:

Stored size: 747 Bytes

Contents

require 'active_support/tagged_logging'
require 'berkeley_library/logging/formatters'

# Monkey-patch ActiveSupport::TaggedLogging::Formatter
# not to produce garbage by prepending tags to hashes.
#
# TODO: Can we intercept Formatter.extend() instead? See
# https://github.com/rails/rails/blob/v6.0.3.4/activesupport/lib/active_support/tagged_logging.rb#L73
module ActiveSupport
  module TaggedLogging
    module Formatter
      def call(severity, time, progname, data)
        return super unless current_tags.present?

        original_data = BerkeleyLibrary::Logging::Formatters.ensure_hash(data)
        merged_data = { tags: current_tags }.merge(original_data)
        super(severity, time, progname, merged_data)
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
berkeley_library-logging-0.2.7 lib/berkeley_library/logging/tagged_logging_extensions.rb
berkeley_library-logging-0.2.6.2 lib/berkeley_library/logging/tagged_logging_extensions.rb
berkeley_library-logging-0.2.6.1 lib/berkeley_library/logging/tagged_logging_extensions.rb
berkeley_library-logging-0.2.6 lib/berkeley_library/logging/tagged_logging_extensions.rb
berkeley_library-logging-0.2.5 lib/berkeley_library/logging/tagged_logging_extensions.rb
berkeley_library-logging-0.2.4 lib/berkeley_library/logging/tagged_logging_extensions.rb
berkeley_library-logging-0.2.3 lib/berkeley_library/logging/tagged_logging_extensions.rb
berkeley_library-logging-0.2.2 lib/berkeley_library/logging/tagged_logging_extensions.rb
berkeley_library-logging-0.2.1 lib/berkeley_library/logging/tagged_logging_extensions.rb
berkeley_library-logging-0.2.0 lib/berkeley_library/logging/tagged_logging_extensions.rb