1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/railties/lib/rails/rack/logger.rb
Prem Sichanugrist & Xavier Noria 68802d0fbe Filter sensitive query string parameters in the log [#6244 state:committed]
This provides more safety to applications that put secret information in the query string, such as API keys or SSO tokens.

Signed-off-by: Xavier Noria <fxn@hashref.com>
2011-03-11 00:16:18 +01:00

33 lines
750 B
Ruby

require 'active_support/core_ext/time/conversions'
module Rails
module Rack
# Log the request started and flush all loggers after it.
class Logger < ActiveSupport::LogSubscriber
def initialize(app)
@app = app
end
def call(env)
before_dispatch(env)
@app.call(env)
ensure
after_dispatch(env)
end
protected
def before_dispatch(env)
request = ActionDispatch::Request.new(env)
path = request.filtered_path
info "\n\nStarted #{request.request_method} \"#{path}\" " \
"for #{request.ip} at #{Time.now.to_default_s}"
end
def after_dispatch(env)
ActiveSupport::LogSubscriber.flush_all!
end
end
end
end