Class: ActionCable::Server::TaggedLoggerProxy
| Relationships & Source Files | |
| Inherits: | Object |
| Defined in: | actioncable/lib/action_cable/server/tagged_logger_proxy.rb |
Overview
Action Cable Connection TaggedLoggerProxy
Allows the use of per-connection tags against the server logger. This wouldn't work using the traditional
::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 Method Summary
- .new(logger, tags:) ⇒ TaggedLoggerProxy constructor
Instance Attribute Summary
- #tags readonly
Instance Method Summary
Constructor Details
.new(logger, tags:) ⇒ TaggedLoggerProxy
# File 'actioncable/lib/action_cable/server/tagged_logger_proxy.rb', line 15
def initialize(logger, tags:) @logger = logger @tags = .flatten end
Instance Attribute Details
#tags (readonly)
[ GitHub ]# File 'actioncable/lib/action_cable/server/tagged_logger_proxy.rb', line 13
attr_reader :
Instance Method Details
#add_tags(*tags)
[ GitHub ]# File 'actioncable/lib/action_cable/server/tagged_logger_proxy.rb', line 20
def (*) @tags += .flatten @tags = @tags.uniq end
#log(type, message, &block) (private)
[ GitHub ]# File 'actioncable/lib/action_cable/server/tagged_logger_proxy.rb', line 41
def log(type, , &block) # :doc: tag(@logger) { @logger.send type, , &block } end
#tag(logger, &block)
[ GitHub ]# File 'actioncable/lib/action_cable/server/tagged_logger_proxy.rb', line 25
def tag(logger, &block) if logger.respond_to?(:tagged) = - logger.formatter. logger.tagged(*, &block) else yield end end