From 43c6c7787954d959347a1f90d71b11ba0cb7a8c7 Mon Sep 17 00:00:00 2001 From: Lachlan Sylvester Date: Wed, 18 Nov 2015 22:53:23 +1100 Subject: Handle cases where logger is not a tagged logger. Previously, a TaggedLoggerProxy was only created if the logger responded to :tagged, but was still used as if it was a TaggedLoggerProxy elsewhere in the code, causing undefined method errors. This moved the check for tagging abilities inside the TaggedLoggerProxy so the code can always tread the logger like a tagged logger, and if it is not a tagged logger the tags will just be ignored. This prevents needing to check if the logger is tagged every time we use it. --- lib/action_cable/connection/base.rb | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'lib/action_cable/connection/base.rb') diff --git a/lib/action_cable/connection/base.rb b/lib/action_cable/connection/base.rb index 6df168e4c3..b93b6a8a50 100644 --- a/lib/action_cable/connection/base.rb +++ b/lib/action_cable/connection/base.rb @@ -56,7 +56,7 @@ module ActionCable def initialize(server, env) @server, @env = server, env - @logger = new_tagged_logger || server.logger + @logger = new_tagged_logger @websocket = ActionCable::Connection::WebSocket.new(env) @subscriptions = ActionCable::Connection::Subscriptions.new(self) @@ -194,10 +194,8 @@ module ActionCable # Tags are declared in the server but computed in the connection. This allows us per-connection tailored tags. def new_tagged_logger - if server.logger.respond_to?(:tagged) - TaggedLoggerProxy.new server.logger, - tags: server.config.log_tags.map { |tag| tag.respond_to?(:call) ? tag.call(request) : tag.to_s.camelize } - end + TaggedLoggerProxy.new server.logger, + tags: server.config.log_tags.map { |tag| tag.respond_to?(:call) ? tag.call(request) : tag.to_s.camelize } end def started_request_message -- cgit v1.2.3