Skip to content

Commit 363abea

Browse files
ghiculescurafaelfranca
authored andcommitted
Refactor Rails::Rack::Logger to avoid adding a new param to call_app
ref: rails#50992 (comment) This refactors the implementation from that PR so that we don't need a new param on the `call_app` method. This means we don't break any gems or apps that have overridden it.
1 parent 9b343c2 commit 363abea

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

railties/lib/rails/rack/logger.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,19 @@ def initialize(app, taggers = nil)
2020
def call(env)
2121
request = ActionDispatch::Request.new(env)
2222

23-
logger_tag_pop_count = if logger.respond_to?(:push_tags)
23+
env["rails.rack_logger_tag_count"] = if logger.respond_to?(:push_tags)
2424
logger.push_tags(*compute_tags(request)).size
2525
else
2626
0
2727
end
28-
call_app(request, env, logger_tag_pop_count)
28+
29+
call_app(request, env)
2930
end
3031

3132
private
32-
def call_app(request, env, logger_tag_pop_count) # :doc:
33+
def call_app(request, env) # :doc:
34+
logger_tag_pop_count = env["rails.rack_logger_tag_count"]
35+
3336
instrumenter = ActiveSupport::Notifications.instrumenter
3437
handle = instrumenter.build_handle("request.action_dispatch", { request: request })
3538
handle.start

0 commit comments

Comments
 (0)