diff options
Diffstat (limited to 'actioncable/lib/action_cable/channel')
-rw-r--r-- | actioncable/lib/action_cable/channel/base.rb | 7 | ||||
-rw-r--r-- | actioncable/lib/action_cable/channel/log_subscriber.rb | 40 |
2 files changed, 6 insertions, 41 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 diff --git a/actioncable/lib/action_cable/channel/log_subscriber.rb b/actioncable/lib/action_cable/channel/log_subscriber.rb deleted file mode 100644 index d58b017e0e..0000000000 --- a/actioncable/lib/action_cable/channel/log_subscriber.rb +++ /dev/null @@ -1,40 +0,0 @@ -require 'active_support/log_subscriber' - -module ActionCable - module Channel - class LogSubscriber < ActiveSupport::LogSubscriber - def perform_action(event) - info do - channel_class = event.payload[:channel_class] - action = event.payload[:action] - "Completed #{channel_class}##{action} in #{event.duration.round}ms" - end - end - - def transmit(event) - info do - channel_class = event.payload[:channel_class] - data = event.payload[:data] - via = event.payload[:via] - "#{channel_class} transmitting #{data.inspect.truncate(300)}".tap { |m| m << " (via #{via})" if via } - end - end - - def transmit_subscription_confirmation(event) - info do - channel_class = event.payload[:channel_class] - "#{channel_class} is transmitting the subscription confirmation" - end - end - - def transmit_subscription_rejection(event) - info do - channel_class = event.payload[:channel_class] - "#{channel_class} is transmitting the subscription rejection" - end - end - end - end -end - -ActionCable::Channel::LogSubscriber.attach_to :action_cable |