instance method
tagged
Ruby on Rails edge
Since edgeSignature
tagged(*tags, &block)
Add the tags to every broadcast that supports tagged logging.
Without a block, it returns a new BroadcastLogger whose tagging-capable broadcasts are tagged, so the result can be logged to directly. Broadcasts that don’t support tagging are kept as-is so they keep receiving messages.
broadcast.tagged("BCX").info("Hello") # All broadcasts log "[BCX] Hello"
With a block, the tags are applied to every tagging-capable broadcast for the duration of the block, which is yielded once with the broadcast logger.
broadcast.tagged("BCX") { |logger| logger.info("Hello") }
Parameters
-
tagsrest -
blockblock
Source
# File activesupport/lib/active_support/broadcast_logger.rb, line 247
def tagged(*tags, &block)
if block
tagging_loggers = @broadcasts.select { |logger| logger.respond_to?(:tagged) }
_tagged(tagging_loggers, 0, tags, &block)
else
loggers = @broadcasts.map { |logger| logger.respond_to?(:tagged) ? logger.tagged(*tags) : logger }
self.class.new(*loggers)
end
end
Defined in activesupport/lib/active_support/broadcast_logger.rb line 247
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveSupport::BroadcastLogger