diff options
author | kp <keith.j.payne@gmail.com> | 2016-02-10 17:11:12 +0000 |
---|---|---|
committer | kp <keith.j.payne@gmail.com> | 2016-02-10 17:11:12 +0000 |
commit | 8641de93eb98d4ebdb0db2530c8c79c0c4e2f95e (patch) | |
tree | a92a1f0361730d1588687f8c62ac956e547932f0 | |
parent | ae9c08f3926ab4669ee7dca1983212182e386c0a (diff) | |
download | rails-8641de93eb98d4ebdb0db2530c8c79c0c4e2f95e.tar.gz rails-8641de93eb98d4ebdb0db2530c8c79c0c4e2f95e.tar.bz2 rails-8641de93eb98d4ebdb0db2530c8c79c0c4e2f95e.zip |
Logs successful and invalid connections separately
-rw-r--r-- | actioncable/lib/action_cable/connection/base.rb | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/actioncable/lib/action_cable/connection/base.rb b/actioncable/lib/action_cable/connection/base.rb index 23e72daff8..de7ff96d7b 100644 --- a/actioncable/lib/action_cable/connection/base.rb +++ b/actioncable/lib/action_cable/connection/base.rb @@ -185,14 +185,14 @@ module ActionCable end def respond_to_successful_request - logger.debug debugged_request + logger.info successful_request_message websocket.rack_response end def respond_to_invalid_request close if websocket.alive? - logger.debug debugged_request + logger.error invalid_request_message logger.info finished_request_message [ 404, { 'Content-Type' => 'text/plain' }, [ 'Page not found' ] ] end @@ -220,12 +220,16 @@ module ActionCable 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( '; ' ) } }" + def invalid_request_message + 'Failed to upgrade to WebSocket (REQUEST_METHOD: %s, HTTP_CONNECTION: %s, HTTP_UPGRADE: %s)' % [ + env["REQUEST_METHOD"], env["HTTP_CONNECTION"], env["HTTP_UPGRADE"] + ] + end + + def successful_request_message + 'Successfully upgraded to WebSocket (REQUEST_METHOD: %s, HTTP_CONNECTION: %s, HTTP_UPGRADE: %s)' % [ + env["REQUEST_METHOD"], env["HTTP_CONNECTION"], env["HTTP_UPGRADE"] + ] end end end |