Improve the logging of Socket.IO Messages

pull/35/head
Peter 'Pita' Martischka 2011-07-11 15:56:45 +02:00
parent e9d6000e01
commit 69d2eba46e
1 changed files with 9 additions and 1 deletions

View File

@ -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])