v1.18.x
Baris Soner Usakli 11 years ago
parent 520fcadd3f
commit aff8cef5f3

@ -32,6 +32,7 @@ var opts = {
Logger.init = function(app) {
opts.express.app = app;
console.log(meta.config);
/* Open log file stream & initialize express logging if meta.config.logger* variables are set */
Logger.setup();
}
@ -65,6 +66,7 @@ var opts = {
else opts.streams.log.f = process.stdout;
}
else {
console.log('CLOSING');
Logger.close(opts.streams.log);
}
}
@ -72,18 +74,26 @@ var opts = {
Logger.open = function(value) {
/* Open the streams to log to: either a path or stdout */
var stream;
if(value && fs.existsSync(value)) {
fs.stat(value, function(err, stats) {
if(value) {
if(fs.existsSync(value)) {
stats = fs.statSync(value);
if(stats) {
if(stats.isDirectory()) {
stream = fs.createWriteStream(path.join(value, 'nodebb.log'), {flags: 'a'});
} else {
stream = fs.createWriteStream(value, {flags: 'a'});
}
}
} else {
stream = fs.createWriteStream(value, {flags: 'a'});
}
if(stream) {
stream.on('error', function(err) {
winston.error(err.message);
});
});
}
} else {
stream = process.stdout;
}
@ -189,8 +199,9 @@ var opts = {
var emit = socket.emit;
socket.emit = function() {
if(opts.streams.log.f != null) {
opts.streams.log.f.write(Logger.prepare_io_string("emit",uid,arguments));
opts.streams.log.f.write(Logger.prepare_io_string("emit", uid, arguments));
}
try {
emit.apply(socket, arguments);
} catch(err) {

Loading…
Cancel
Save