Class: ActionCable::Connection::TaggedLoggerProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/action_cable/connection/tagged_logger_proxy.rb

Overview

Allows the use of per-connection tags against the server logger. This wouldn't work using the tradional 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.

Instance Method Summary collapse

Constructor Details

#initialize(logger, tags:) ⇒ TaggedLoggerProxy

Returns a new instance of TaggedLoggerProxy.


7
8
9
10
# File 'lib/action_cable/connection/tagged_logger_proxy.rb', line 7

def initialize(logger, tags:)
  @logger = logger
  @tags = tags.flatten
end

Instance Method Details

#add_tags(*tags) ⇒ Object


12
13
14
15
# File 'lib/action_cable/connection/tagged_logger_proxy.rb', line 12

def add_tags(*tags)
  @tags += tags.flatten
  @tags = @tags.uniq
end