diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2015-02-09 21:22:32 -0800 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2015-02-09 21:22:32 -0800 |
commit | c0936fbf1f332a6fc2c68a1dc3f52b327e63f0b2 (patch) | |
tree | 8a4e09f5665604f6cf0da453f0bd1e66588ba0fa /lib | |
parent | 9b8195b4b03e9ee70bde3072e364826f198d9fb2 (diff) | |
download | rails-c0936fbf1f332a6fc2c68a1dc3f52b327e63f0b2.tar.gz rails-c0936fbf1f332a6fc2c68a1dc3f52b327e63f0b2.tar.bz2 rails-c0936fbf1f332a6fc2c68a1dc3f52b327e63f0b2.zip |
Add logging
Diffstat (limited to 'lib')
-rw-r--r-- | lib/action_cable/server.rb | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/action_cable/server.rb b/lib/action_cable/server.rb index 96d21416bf..8f72d2ca7b 100644 --- a/lib/action_cable/server.rb +++ b/lib/action_cable/server.rb @@ -6,6 +6,8 @@ module ActionCable class_attribute :worker_pool_size self.worker_pool_size = 100 + cattr_accessor(:logger, instance_reader: true) { Rails.logger } + class << self def register_channels(*channel_classes) self.registered_channels += channel_classes @@ -66,6 +68,7 @@ module ActionCable end def broadcast(data) + logger.info "Sending data: #{data}" @websocket.send data end @@ -81,19 +84,23 @@ module ActionCable subscription_klass = registered_channels.detect { |channel_klass| channel_klass.find_name == id_options[:channel] } if subscription_klass + logger.info "Subscribing to channel: #{id_key}" @subscriptions[id_key] = subscription_klass.new(self, id_key, id_options) else - # No channel found + logger.error "Unable to subscribe to channel: #{id_key}" end end def process_message(message) if @subscriptions[message['identifier']] @subscriptions[message['identifier']].receive(ActiveSupport::JSON.decode message['data']) + else + logger.error "Unable to process message: #{message}" end end def unsubscribe_channel(data) + logger.info "Unsubscribing from channel: #{data['identifier']}" @subscriptions[data['identifier']].unsubscribe @subscriptions.delete(data['identifier']) end |