Last active
May 20, 2016 22:13
-
-
Save jdfreder/2bfd8d739525ff56f267 to your computer and use it in GitHub Desktop.
Log websocket messages
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Dump this into your web console in a live notebook | |
function safeLog(type) { | |
try { | |
console.log.apply(console, arguments); | |
} catch(err) { | |
console.warn(type, 'could not print data'); | |
} | |
} | |
var orig1 = Jupyter.notebook.kernel.ws.onmessage; | |
Jupyter.notebook.kernel.ws.onmessage = function() { | |
safeLog('recv', JSON.parse(arguments[0].data)); | |
return orig1.apply(Jupyter.notebook.kernel.ws, arguments); | |
}; | |
var orig2 = Jupyter.notebook.kernel.ws.send; | |
Jupyter.notebook.kernel.ws.send = function() { | |
safeLog('send', arguments); | |
return orig2.apply(Jupyter.notebook.kernel.ws, arguments); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment