Sha256: 24dd52f3ad533e4f49c624aede2e0e2ba01a8dd6d05174299138be7c1906c30e

Contents?: true

Size: 715 Bytes

Versions: 4

Compression:

Stored size: 715 Bytes

Contents

module Lumberjack
  module Rack
    # Support for using the Rails ActionDispatch request id in the log.
    # The format is expected to be a random UUID and only the first chunk is used for terseness
    # if the abbreviated argument is true.
    class RequestId
      REQUEST_ID = "action_dispatch.request_id".freeze
  
      def initialize(app, abbreviated = false)
        @app = app
        @abbreviated = abbreviated
      end
  
      def call(env)
        request_id = env[REQUEST_ID]
        if request_id && @abbreviated
          request_id = request_id.split('-'.freeze, 2).first
        end
        Lumberjack.unit_of_work(request_id) do
          @app.call(env)
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 3 rubygems

Version Path
comiditaULL-0.1.1 vendor/bundle/ruby/2.3.0/gems/lumberjack-1.0.12/lib/lumberjack/rack/request_id.rb
comidita_ull-0.1.1 vendor/bundle/ruby/2.3.0/gems/lumberjack-1.0.12/lib/lumberjack/rack/request_id.rb
comidita_ull-0.1.0 vendor/bundle/ruby/2.3.0/gems/lumberjack-1.0.12/lib/lumberjack/rack/request_id.rb
lumberjack-1.0.12 lib/lumberjack/rack/request_id.rb