|
|
@ -175,11 +175,12 @@ var opts = {
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* Go through all of the currently established sockets & hook their .emit/.on
|
|
|
|
* Go through all of the currently established sockets & hook their .emit/.on
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
if(!socket && !socket.io.sockets) {
|
|
|
|
|
|
|
|
|
|
|
|
if (!socket || !socket.io || !socket.io.sockets || !Array.isArray(socket.io.sockets.sockets)) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var clients = []; //socket.io.sockets.clients(); doesn't work in socket.io 1.x
|
|
|
|
var clients = socket.io.sockets.sockets;
|
|
|
|
|
|
|
|
|
|
|
|
clients.forEach(function(client) {
|
|
|
|
clients.forEach(function(client) {
|
|
|
|
Logger.io_one(client, client.uid);
|
|
|
|
Logger.io_one(client, client.uid);
|
|
|
@ -190,33 +191,29 @@ var opts = {
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* This function replaces a socket's .emit/.on functions in order to intercept events
|
|
|
|
* This function replaces a socket's .emit/.on functions in order to intercept events
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
if(socket && meta.config.loggerIOStatus > 0) {
|
|
|
|
function override(method, name, errorMsg) {
|
|
|
|
|
|
|
|
return function() {
|
|
|
|
(function() {
|
|
|
|
if(opts.streams.log.f) {
|
|
|
|
function override(method, name, errorMsg) {
|
|
|
|
opts.streams.log.f.write(Logger.prepare_io_string(name, uid, arguments));
|
|
|
|
return function() {
|
|
|
|
|
|
|
|
if(opts.streams.log.f) {
|
|
|
|
|
|
|
|
opts.streams.log.f.write(Logger.prepare_io_string(name, uid, arguments));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
method.apply(socket, arguments);
|
|
|
|
|
|
|
|
} catch(err) {
|
|
|
|
|
|
|
|
winston.info(errorMsg, err);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// courtesy of: http://stackoverflow.com/a/9674248
|
|
|
|
try {
|
|
|
|
socket.oEmit = socket.emit;
|
|
|
|
method.apply(socket, arguments);
|
|
|
|
var emit = socket.emit;
|
|
|
|
} catch(err) {
|
|
|
|
socket.emit = override(emit, 'emit', 'Logger.io_one: emit.apply: Failed');
|
|
|
|
winston.info(errorMsg, err);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
socket.$oEmit = socket.$emit;
|
|
|
|
if (socket && meta.config.loggerIOStatus > 0) {
|
|
|
|
var $emit = socket.$emit;
|
|
|
|
// courtesy of: http://stackoverflow.com/a/9674248
|
|
|
|
socket.$emit = override($emit, 'on', 'Logger.io_one: $emit.apply: Failed');
|
|
|
|
socket.oEmit = socket.emit;
|
|
|
|
|
|
|
|
var emit = socket.emit;
|
|
|
|
|
|
|
|
socket.emit = override(emit, 'emit', 'Logger.io_one: emit.apply: Failed');
|
|
|
|
|
|
|
|
|
|
|
|
})();
|
|
|
|
socket.$oEmit = socket.$emit;
|
|
|
|
|
|
|
|
var $emit = socket.$emit;
|
|
|
|
|
|
|
|
socket.$emit = override($emit, 'on', 'Logger.io_one: $emit.apply: Failed');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|