aboutsummaryrefslogtreecommitdiffstats
path: root/actioncable/lib/action_cable/channel/base.rb
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2016-03-30 00:03:11 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2016-03-30 00:03:11 -0300
commitedbfd10876f938bd04b9034b1e4c4329cd4f2d2b (patch)
tree60306d702cb95cb0a3113db37b602eb0cf10ac2f /actioncable/lib/action_cable/channel/base.rb
parent6786718766f10ef25af427a43e47c15ee02dc7e5 (diff)
downloadrails-edbfd10876f938bd04b9034b1e4c4329cd4f2d2b.tar.gz
rails-edbfd10876f938bd04b9034b1e4c4329cd4f2d2b.tar.bz2
rails-edbfd10876f938bd04b9034b1e4c4329cd4f2d2b.zip
Keep logging in the ActionCable::Channel::Base
To move Action Cable logging to a LoggingSubscriber we need to pass the log tags in the notification payload since Action Cable logging use the Channel instance to tag the logs.
Diffstat (limited to 'actioncable/lib/action_cable/channel/base.rb')
-rw-r--r--actioncable/lib/action_cable/channel/base.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/actioncable/lib/action_cable/channel/base.rb b/actioncable/lib/action_cable/channel/base.rb
index a0319eb522..464d0581dd 100644
--- a/actioncable/lib/action_cable/channel/base.rb
+++ b/actioncable/lib/action_cable/channel/base.rb
@@ -1,4 +1,3 @@
-require 'action_cable/channel/log_subscriber'
require 'set'
module ActionCable
@@ -195,6 +194,8 @@ 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)
+ logger.info "#{self.class.name} transmitting #{data.inspect.truncate(300)}".tap { |m| m << " (via #{via})" if via }
+
payload = { channel_class: self.class.name, data: data, via: via }
ActiveSupport::Notifications.instrument("transmit.action_cable", payload) do
connection.transmit ActiveSupport::JSON.encode(identifier: @identifier, message: data)
@@ -270,6 +271,8 @@ module ActionCable
def transmit_subscription_confirmation
unless subscription_confirmation_sent?
+ logger.info "#{self.class.name} is transmitting the subscription confirmation"
+
ActiveSupport::Notifications.instrument("transmit_subscription_confirmation.action_cable", channel_class: self.class.name) do
connection.transmit ActiveSupport::JSON.encode(identifier: @identifier, type: ActionCable::INTERNAL[:message_types][:confirmation])
@subscription_confirmation_sent = true
@@ -283,6 +286,8 @@ module ActionCable
end
def transmit_subscription_rejection
+ logger.info "#{self.class.name} is transmitting the subscription rejection"
+
ActiveSupport::Notifications.instrument("transmit_subscription_rejection.action_cable", channel_class: self.class.name) do
connection.transmit ActiveSupport::JSON.encode(identifier: @identifier, type: ActionCable::INTERNAL[:message_types][:rejection])
end