1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Log error stack traces if verbose flag is set

This commit is contained in:
Nick O'Leary 2017-03-01 17:00:27 +00:00
parent 571b9fb8e0
commit 54ee655472
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9

View File

@ -44,6 +44,8 @@ var levelNames = {
var logHandlers = [];
var verbose;
var metricsEnabled = false;
var LogHandler = function(settings) {
@ -71,6 +73,9 @@ LogHandler.prototype.shouldReportMessage = function(msglevel) {
var consoleLogger = function(msg) {
if (msg.level == log.METRIC || msg.level == log.AUDIT) {
util.log("["+levelNames[msg.level]+"] "+JSON.stringify(msg));
} else {
if (verbose && msg.msg.stack) {
util.log("["+levelNames[msg.level]+"] "+(msg.type?"["+msg.type+":"+(msg.name||msg.id)+"] ":"")+msg.msg.stack);
} else {
var message = msg.msg;
if (typeof message === 'object' && message.toString() === '[object Object]' && message.message) {
@ -79,6 +84,7 @@ var consoleLogger = function(msg) {
util.log("["+levelNames[msg.level]+"] "+(msg.type?"["+msg.type+":"+(msg.name||msg.id)+"] ":"")+message);
}
}
}
var log = module.exports = {
FATAL: 10,
@ -94,6 +100,7 @@ var log = module.exports = {
metricsEnabled = false;
logHandlers = [];
var loggerSettings = {};
verbose = settings.verbose;
if (settings.logging) {
var keys = Object.keys(settings.logging);
if (keys.length === 0) {