Class: ActionCable::Connection::TaggedLoggerProxy

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

Instance Method Summary collapse

Instance Method Details

#tag(logger) ⇒ Object

Mirrors upstream #tag, including the respond_to?(:tagged) guard so a target logger without tagging support (e.g. when handed a non-tagged ActiveRecord::Base.logger by the worker pool) simply yields. Diverges in one place: upstream reads the already-applied tags via logger.formatter.current_tags (ActiveSupport::TaggedLogging), but Semantic Logger exposes them via #tags, so resolve from whichever the target logger supports. See #220.



17
18
19
20
21
22
23
24
# File 'lib/rails_semantic_logger/extensions/action_cable/tagged_logger_proxy.rb', line 17

def tag(logger, &)
  if logger.respond_to?(:tagged)
    current_tags = tags - applied_tags_for(logger)
    logger.tagged(*current_tags, &)
  else
    yield
  end
end