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 logHandlers = [];
var verbose;
var metricsEnabled = false; var metricsEnabled = false;
var LogHandler = function(settings) { var LogHandler = function(settings) {
@ -72,11 +74,15 @@ var consoleLogger = function(msg) {
if (msg.level == log.METRIC || msg.level == log.AUDIT) { if (msg.level == log.METRIC || msg.level == log.AUDIT) {
util.log("["+levelNames[msg.level]+"] "+JSON.stringify(msg)); util.log("["+levelNames[msg.level]+"] "+JSON.stringify(msg));
} else { } else {
var message = msg.msg; if (verbose && msg.msg.stack) {
if (typeof message === 'object' && message.toString() === '[object Object]' && message.message) { util.log("["+levelNames[msg.level]+"] "+(msg.type?"["+msg.type+":"+(msg.name||msg.id)+"] ":"")+msg.msg.stack);
message = message.message; } else {
var message = msg.msg;
if (typeof message === 'object' && message.toString() === '[object Object]' && message.message) {
message = message.message;
}
util.log("["+levelNames[msg.level]+"] "+(msg.type?"["+msg.type+":"+(msg.name||msg.id)+"] ":"")+message);
} }
util.log("["+levelNames[msg.level]+"] "+(msg.type?"["+msg.type+":"+(msg.name||msg.id)+"] ":"")+message);
} }
} }
@ -94,6 +100,7 @@ var log = module.exports = {
metricsEnabled = false; metricsEnabled = false;
logHandlers = []; logHandlers = [];
var loggerSettings = {}; var loggerSettings = {};
verbose = settings.verbose;
if (settings.logging) { if (settings.logging) {
var keys = Object.keys(settings.logging); var keys = Object.keys(settings.logging);
if (keys.length === 0) { if (keys.length === 0) {