From 69d2eba46eeab1e6351c6063d4b43f7e1b7f2048 Mon Sep 17 00:00:00 2001 From: Peter 'Pita' Martischka Date: Mon, 11 Jul 2011 15:56:45 +0200 Subject: [PATCH] Improve the logging of Socket.IO Messages --- node/SocketIORouter.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/node/SocketIORouter.js b/node/SocketIORouter.js index 81f8e683d..03dd5ac25 100644 --- a/node/SocketIORouter.js +++ b/node/SocketIORouter.js @@ -50,6 +50,14 @@ exports.setSocketIO = function(_socket) socket.sockets.on('connection', function(client) { + //wrap the original send function to log the messages + client._send = client.send; + client.send = function(message) + { + console.log(new Date().toUTCString() + ": message to " + client.id + ": " + JSON.stringify(message)); + client._send(message); + } + //tell all components about this connect for(var i in components) { @@ -67,7 +75,7 @@ exports.setSocketIO = function(_socket) //route this message to the correct component, if possible if(message.component && components[message.component]) { - console.error(message); + console.log(new Date().toUTCString() + ": message from " + client.id + ": " + JSON.stringify(message)); //check if component is registered in the components array if(components[message.component])