aboutsummaryrefslogtreecommitdiffstats
path: root/lib/action_cable/connection/tagged_logger_proxy.rb
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2015-10-12 12:33:48 -0500
committerPratik Naik <pratiknaik@gmail.com>2015-10-12 12:33:48 -0500
commitd222f7de572f28fc2fa185e9f21cac6f7e6c84f0 (patch)
treebc3b9edb6e85119f172c1367fd96826367b1948d /lib/action_cable/connection/tagged_logger_proxy.rb
parentaa3c1154edfacecbbf676af4d8728d8674d97cf4 (diff)
downloadrails-d222f7de572f28fc2fa185e9f21cac6f7e6c84f0.tar.gz
rails-d222f7de572f28fc2fa185e9f21cac6f7e6c84f0.tar.bz2
rails-d222f7de572f28fc2fa185e9f21cac6f7e6c84f0.zip
Make sure active record queries are logged with the current connection tags
Diffstat (limited to 'lib/action_cable/connection/tagged_logger_proxy.rb')
-rw-r--r--lib/action_cable/connection/tagged_logger_proxy.rb5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/action_cable/connection/tagged_logger_proxy.rb b/lib/action_cable/connection/tagged_logger_proxy.rb
index 854f613f1c..34063c1d42 100644
--- a/lib/action_cable/connection/tagged_logger_proxy.rb
+++ b/lib/action_cable/connection/tagged_logger_proxy.rb
@@ -4,6 +4,8 @@ module ActionCable
# ActiveSupport::TaggedLogging-enhanced Rails.logger, as that logger will reset the tags between requests.
# The connection is long-lived, so it needs its own set of tags for its independent duration.
class TaggedLoggerProxy
+ attr_reader :tags
+
def initialize(logger, tags:)
@logger = logger
@tags = tags.flatten
@@ -22,7 +24,8 @@ module ActionCable
protected
def log(type, message)
- @logger.tagged(*@tags) { @logger.send type, message }
+ current_tags = tags - @logger.formatter.current_tags
+ @logger.tagged(*current_tags) { @logger.send type, message }
end
end
end