Project

General

Profile

« Previous | Next » 

Revision 9d460533

Added by Lukas Zapletal over 5 years ago

Fixes #25100 - Ruby logging stack replaced with logging gem

View differences:

lib/proxy/request_id_middleware.rb
end
def call(env)
Thread.current.thread_variable_set(:request_id, env['HTTP_X_REQUEST_ID']) if env.has_key?('HTTP_X_REQUEST_ID')
::Logging.mdc['remote_ip'] = env['REMOTE_ADDR']
if env.has_key?('HTTP_X_REQUEST_ID')
::Logging.mdc['request'] = env['HTTP_X_REQUEST_ID']
else
::Logging.mdc['request'] = SecureRandom.uuid
end
status, header, body = @app.call(env)
[status, header, ::Rack::BodyProxy.new(body) { Thread.current.thread_variable_set(:request_id, nil) }]
[status, header, ::Rack::BodyProxy.new(body) { ::Logging.mdc.clear }]
end
end
end

Also available in: Unified diff