mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-12 08:55:47 +01:00
@@ -13,40 +13,7 @@ function setupWinston() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// allow winton.error to log error objects properly
|
|
||||||
// https://github.com/NodeBB/NodeBB/issues/6848
|
|
||||||
const winstonError = winston.error;
|
|
||||||
winston.error = function (msg, error) {
|
|
||||||
if (msg instanceof Error) {
|
|
||||||
winstonError(msg);
|
|
||||||
} else if (error instanceof Error) {
|
|
||||||
msg = msg + '\n' + error.stack;
|
|
||||||
winstonError(msg);
|
|
||||||
} else {
|
|
||||||
winstonError.apply(null, arguments);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// https://github.com/winstonjs/winston/issues/1338
|
|
||||||
// error objects are not displayed properly
|
|
||||||
const enumerateErrorFormat = winston.format((info) => {
|
|
||||||
if (info.message instanceof Error) {
|
|
||||||
info.message = Object.assign({
|
|
||||||
message: `${info.message.message}\n${info.message.stack}`,
|
|
||||||
}, info.message);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (info instanceof Error) {
|
|
||||||
return Object.assign({
|
|
||||||
message: `${info.message}\n${info.stack}`,
|
|
||||||
}, info);
|
|
||||||
}
|
|
||||||
|
|
||||||
return info;
|
|
||||||
});
|
|
||||||
var formats = [];
|
var formats = [];
|
||||||
formats.push(enumerateErrorFormat());
|
|
||||||
if (nconf.get('log-colorize') !== 'false') {
|
if (nconf.get('log-colorize') !== 'false') {
|
||||||
formats.push(winston.format.colorize());
|
formats.push(winston.format.colorize());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user