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

@ -3,11 +3,12 @@
*/ */
var fs = require('fs'), var fs = require('fs'),
path = require('path'),
express = require('express'), express = require('express'),
winston = require('winston'), winston = require('winston'),
util = require('util'), util = require('util'),
socketio = require('socket.io'), socketio = require('socket.io'),
meta = require('./meta.js'); meta = require('./meta');
var opts = { var opts = {
/* /*
@ -72,10 +73,20 @@ var opts = {
/* 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 && fs.existsSync(value)) { if(value && fs.existsSync(value)) {
fs.stat(value, function(err, stats) {
if(stats.isDirectory()) {
stream = fs.createWriteStream(path.join(value, 'nodebb.log'), {flags: 'a'});
} else {
stream = fs.createWriteStream(value, {flags: 'a'}); stream = fs.createWriteStream(value, {flags: 'a'});
} }
else stream.on('error', function(err) {
winston.error(err.message);
});
});
} else {
stream = process.stdout; stream = process.stdout;
}
return stream; return stream;
} }
@ -112,8 +123,7 @@ var opts = {
*/ */
if(meta.config.loggerStatus > 0) { if(meta.config.loggerStatus > 0) {
return opts.express.ofn(req,res,next); return opts.express.ofn(req,res,next);
} } else {
else {
return next(); return next();
} }
} }
@ -140,13 +150,15 @@ var opts = {
for(var v in clients) { for(var v in clients) {
var client = clients[v]; var client = clients[v];
if(client.oEmit != undefined && client.oEmit != client.emit) if(client.oEmit != undefined && client.oEmit != client.emit) {
client.emit = client.oEmit; client.emit = client.oEmit;
}
if(client.$oEmit != undefined && client.$oEmit != client.$emit) if(client.$oEmit != undefined && client.$oEmit != client.$emit) {
client.$emit = client.$oEmit; client.$emit = client.$oEmit;
} }
} }
}
Logger.io = function(socket) { Logger.io = function(socket) {
/* /*

Loading…
Cancel
Save