Skip to content

Commit

Permalink
Merge pull request rails#51053 from ghiculescu/dont-redefine-call_app
Browse files Browse the repository at this point in the history
Refactor `Rails::Rack::Logger` to avoid adding a new param to `call_app`
  • Loading branch information
rafaelfranca authored Feb 15, 2024
2 parents 7d4a39c + 363abea commit 9e01d93
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions railties/lib/rails/rack/logger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,19 @@ def initialize(app, taggers = nil)
def call(env)
request = ActionDispatch::Request.new(env)

logger_tag_pop_count = if logger.respond_to?(:push_tags)
env["rails.rack_logger_tag_count"] = if logger.respond_to?(:push_tags)
logger.push_tags(*compute_tags(request)).size
else
0
end
call_app(request, env, logger_tag_pop_count)

call_app(request, env)
end

private
def call_app(request, env, logger_tag_pop_count) # :doc:
def call_app(request, env) # :doc:
logger_tag_pop_count = env["rails.rack_logger_tag_count"]

instrumenter = ActiveSupport::Notifications.instrumenter
handle = instrumenter.build_handle("request.action_dispatch", { request: request })
handle.start
Expand Down

0 comments on commit 9e01d93

Please sign in to comment.