ActionCable::Connection::TaggedLoggerProxy (original) (raw)
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.
Methods
A
L
N
T
Attributes
Class Public methods
new(logger, tags:)Link
def initialize(logger, tags:) @logger = logger @tags = tags.flatten end
Instance Public methods
add_tags(*tags)Link
tag(logger, &block)Link
def tag(logger, &block) if logger.respond_to?(:tagged) current_tags = tags - logger.formatter.current_tags logger.tagged(*current_tags, &block) else yield end end
Instance Private methods
log(type, message, &block)Link
def log(type, message, &block) tag(@logger) { @logger.send type, message, &block } end