mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #44454 from jhawthorn/rack_logger_finish_with_state
Use finish_with_state inside Rack::Logger
This commit is contained in:
commit
0a44c3f90b
1 changed files with 7 additions and 8 deletions
|
@ -31,13 +31,17 @@ module Rails
|
|||
private
|
||||
def call_app(request, env) # :doc:
|
||||
instrumenter = ActiveSupport::Notifications.instrumenter
|
||||
instrumenter.start "request.action_dispatch", request: request
|
||||
instrumenter_state = instrumenter.start "request.action_dispatch", request: request
|
||||
instrumenter_finish = -> () {
|
||||
instrumenter.finish_with_state(instrumenter_state, "request.action_dispatch", request: request)
|
||||
}
|
||||
|
||||
logger.info { started_request_message(request) }
|
||||
status, headers, body = @app.call(env)
|
||||
body = ::Rack::BodyProxy.new(body) { finish(request) }
|
||||
body = ::Rack::BodyProxy.new(body, &instrumenter_finish)
|
||||
[status, headers, body]
|
||||
rescue Exception
|
||||
finish(request)
|
||||
instrumenter_finish.call
|
||||
raise
|
||||
ensure
|
||||
ActiveSupport::LogSubscriber.flush_all!
|
||||
|
@ -65,11 +69,6 @@ module Rails
|
|||
end
|
||||
end
|
||||
|
||||
def finish(request)
|
||||
instrumenter = ActiveSupport::Notifications.instrumenter
|
||||
instrumenter.finish "request.action_dispatch", request: request
|
||||
end
|
||||
|
||||
def logger
|
||||
Rails.logger
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue