diff options
author | kp <keith.j.payne@gmail.com> | 2016-01-26 20:56:50 +0000 |
---|---|---|
committer | kp <keith.j.payne@gmail.com> | 2016-01-26 23:19:49 +0000 |
commit | ae9c08f3926ab4669ee7dca1983212182e386c0a (patch) | |
tree | b3c62823a96688235f20641cb487aa346cfaf172 | |
parent | 755f7b58953c25790eea0574ff8928033ded2d88 (diff) | |
download | rails-ae9c08f3926ab4669ee7dca1983212182e386c0a.tar.gz rails-ae9c08f3926ab4669ee7dca1983212182e386c0a.tar.bz2 rails-ae9c08f3926ab4669ee7dca1983212182e386c0a.zip |
adds debug logging to actioncable connect
-rw-r--r-- | actioncable/lib/action_cable/connection/base.rb | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/actioncable/lib/action_cable/connection/base.rb b/actioncable/lib/action_cable/connection/base.rb index 0016d1a1a4..23e72daff8 100644 --- a/actioncable/lib/action_cable/connection/base.rb +++ b/actioncable/lib/action_cable/connection/base.rb @@ -185,12 +185,14 @@ module ActionCable end def respond_to_successful_request + logger.debug debugged_request websocket.rack_response end def respond_to_invalid_request close if websocket.alive? + logger.debug debugged_request logger.info finished_request_message [ 404, { 'Content-Type' => 'text/plain' }, [ 'Page not found' ] ] end @@ -205,7 +207,7 @@ module ActionCable 'Started %s "%s"%s for %s at %s' % [ request.request_method, request.filtered_path, - websocket.possible? ? ' [WebSocket]' : '', + websocket.possible? ? ' [WebSocket]' : '[non-WebSocket]', request.ip, Time.now.to_s ] end @@ -213,10 +215,18 @@ module ActionCable def finished_request_message 'Finished "%s"%s for %s at %s' % [ request.filtered_path, - websocket.possible? ? ' [WebSocket]' : '', + websocket.possible? ? ' [WebSocket]' : '[non-WebSocket]', request.ip, Time.now.to_s ] end + + def debugged_request + websocket_values = [] + [ "REQUEST_METHOD", + "HTTP_CONNECTION", + "HTTP_UPGRADE" ].each { |key| websocket_values << "#{key} => '#{env[key]}'" } + "This is #{ websocket.possible? ? '' : 'NOT ' }a valid WebSocket request: { #{ websocket_values.join( '; ' ) } }" + end end end end |