just some text formatting fixes

v1.18.x
Andrew Darqui 12 years ago
parent a3f6fee41f
commit 7c1f7e7a23

@ -23,6 +23,9 @@ var opts = {
} }
}; };
/* -- Logger -- */
(function(Logger) { (function(Logger) {
@ -51,7 +54,10 @@ var opts = {
} }
Logger.setup_one_log = function(value) { Logger.setup_one_log = function(value) {
/*
* If logging is currently enabled, create a stream.
* Otherwise, close the current stream
*/
if(meta.config.loggerStatus > 0 || meta.config.loggerIOStatus) { if(meta.config.loggerStatus > 0 || meta.config.loggerIOStatus) {
var stream = Logger.open(value); var stream = Logger.open(value);
if(stream) opts.streams.log.f = stream; if(stream) opts.streams.log.f = stream;
@ -60,18 +66,15 @@ var opts = {
else { else {
Logger.close(opts.streams.log); Logger.close(opts.streams.log);
} }
} }
Logger.open = function(value) { Logger.open = function(value) {
/* Open the streams to log to: either a path or stdout */ /* Open the streams to log to: either a path or stdout */
var stream; var stream;
if(value) if(value)
stream = fs.createWriteStream(value, {flags: 'a'}); stream = fs.createWriteStream(value, {flags: 'a'});
else else
stream = process.stdout; stream = process.stdout;
return stream; return stream;
} }
@ -145,6 +148,9 @@ var opts = {
} }
Logger.io = function(socket) { Logger.io = function(socket) {
/*
* Go through all of the currently established sockets & hook their .emit/.on
*/
if(socket == undefined && socket.io.sockets == undefined) { if(socket == undefined && socket.io.sockets == undefined) {
return; return;
} }
@ -186,7 +192,7 @@ var opts = {
opts.streams.log.f.write(Logger.prepare_io_string("on",uid,arguments)); opts.streams.log.f.write(Logger.prepare_io_string("on",uid,arguments));
} }
try { try {
$emit.apply(socket, arguments); $emit.apply(socket, arguments);
} catch(err) { } catch(err) {
winston.info("Logger.io_one: $emit.apply: Failed", err); winston.info("Logger.io_one: $emit.apply: Failed", err);
} }

Loading…
Cancel
Save