Sha256: f32a225083840d6409b0fed1ef62bea298709a834e0a979389a8f58fa2e93cc8

Contents?: true

Size: 446 Bytes

Versions: 3

Compression:

Stored size: 446 Bytes

Contents

# frozen_string_literal: true

require "request_store"

module Marlowe
  # Marlowe::Formatter is a subclass of +ActiveSupport::Logger::Formatter+
  # that adds a correlation id string to a rails log.
  class Formatter < ActiveSupport::Logger::Formatter
    # Overrides the formatter return to add the correlation id.
    def call(_severity, _timestamp, _progname, _msg)
      "[#{RequestStore.store[:correlation_id]}] #{super}"
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
marlowe-3.1 lib/marlowe/formatter.rb
marlowe-3.0 lib/marlowe/formatter.rb
marlowe-2.1 lib/marlowe/formatter.rb