Sha256: 45a19ade42d7db14a767147495cdc478b9847055441e0c020ee3edc741e86e46

Contents?: true

Size: 471 Bytes

Versions: 8

Compression:

Stored size: 471 Bytes

Contents

module Rack
	class XIDLogging
		def initialize(app, root_logger, header_name = 'XID', &block)
			@root_logger = root_logger
			@header_name = header_name
			@app = app
		end

		def call(env)
			begin
				xid = env["HTTP_#{@header_name.upcase.tr('-', '_')}"]
				if xid
					env['xid'] = {@header_name => xid}
					@root_logger.with_meta_context(xid: xid) do
						return @app.call(env)
					end
				else
					return @app.call(env)
				end
			ensure
			end
		end
	end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
unicorn-cuba-base-1.6.0 lib/unicorn-cuba-base/rack/xid_logging.rb
unicorn-cuba-base-1.5.0 lib/unicorn-cuba-base/rack/xid_logging.rb
unicorn-cuba-base-1.4.1 lib/unicorn-cuba-base/rack/xid_logging.rb
unicorn-cuba-base-1.4.0 lib/unicorn-cuba-base/rack/xid_logging.rb
unicorn-cuba-base-1.3.0 lib/unicorn-cuba-base/rack/xid_logging.rb
unicorn-cuba-base-1.2.2 lib/unicorn-cuba-base/rack/xid_logging.rb
unicorn-cuba-base-1.2.1 lib/unicorn-cuba-base/rack/xid_logging.rb
unicorn-cuba-base-1.2.0 lib/unicorn-cuba-base/rack/xid_logging.rb