mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-08-05 00:40:40 +02:00
Override winston to use console.log instead of stdout
This commit is contained in:
17
app.js
17
app.js
@@ -37,6 +37,7 @@ var winston = require('winston');
|
||||
var path = require('path');
|
||||
var pkg = require('./package.json');
|
||||
var file = require('./src/file');
|
||||
var debug = require('./src/meta/debugParams')().execArgv.length;
|
||||
|
||||
global.env = process.env.NODE_ENV || 'production';
|
||||
|
||||
@@ -52,6 +53,22 @@ winston.add(winston.transports.Console, {
|
||||
stringify: (!!nconf.get('json-logging')),
|
||||
});
|
||||
|
||||
if (debug) {
|
||||
var winstonCommon = require('winston/lib/winston/common');
|
||||
// Override to use real console.log etc for VSCode debugger
|
||||
winston.transports.Console.prototype.log = function (level, message, meta, callback) {
|
||||
const output = winstonCommon.log(Object.assign({}, this, {
|
||||
level,
|
||||
message,
|
||||
meta,
|
||||
}));
|
||||
|
||||
console[level in console ? level : 'log'](output);
|
||||
|
||||
setImmediate(callback, null, true);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
// Alternate configuration file support
|
||||
var configFile = path.join(__dirname, '/config.json');
|
||||
|
||||
Reference in New Issue
Block a user