mirror of https://github.com/rails/rails
Merge pull request #48772 from mhib/tagged-logger-proxy-block-support
Prevent inspecting transmit data if not necessary
This commit is contained in:
commit
ea9b647806
|
@ -212,9 +212,11 @@ module ActionCable
|
|||
# Transmit a hash of data to the subscriber. The hash will automatically be wrapped in a JSON envelope with
|
||||
# the proper channel identifier marked as the recipient.
|
||||
def transmit(data, via: nil) # :doc:
|
||||
status = "#{self.class.name} transmitting #{data.inspect.truncate(300)}"
|
||||
status += " (via #{via})" if via
|
||||
logger.debug(status)
|
||||
logger.debug do
|
||||
status = "#{self.class.name} transmitting #{data.inspect.truncate(300)}"
|
||||
status += " (via #{via})" if via
|
||||
status
|
||||
end
|
||||
|
||||
payload = { channel_class: self.class.name, data: data, via: via }
|
||||
ActiveSupport::Notifications.instrument("transmit.action_cable", payload) do
|
||||
|
|
|
@ -30,14 +30,14 @@ module ActionCable
|
|||
end
|
||||
|
||||
%i( debug info warn error fatal unknown ).each do |severity|
|
||||
define_method(severity) do |message|
|
||||
log severity, message
|
||||
define_method(severity) do |message = nil, &block|
|
||||
log severity, message, &block
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def log(type, message) # :doc:
|
||||
tag(@logger) { @logger.send type, message }
|
||||
def log(type, message, &block) # :doc:
|
||||
tag(@logger) { @logger.send type, message, &block }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue