Skip to content

Commit

Permalink
nice print of unhandled exception stack trace
Browse files Browse the repository at this point in the history
  • Loading branch information
samzilverberg authored and indexzero committed Feb 3, 2015
1 parent 359c524 commit 50163a0
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion lib/winston/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,26 @@ exports.log = function (options) {
output += ' ' + options.prettyPrint(meta);
} else if (options.prettyPrint) {
output += ' ' + '\n' + util.inspect(meta, false, options.depth || null, options.colorize);
} else {
} else if (
Object.keys(meta).length === 5
&& meta.hasOwnProperty('date')
&& meta.hasOwnProperty('process')
&& meta.hasOwnProperty('os')
&& meta.hasOwnProperty('trace')
&& meta.hasOwnProperty('stack')) {

//
// If meta carries unhandled exception data serialize the stack nicely
//
var stack = meta.stack;
delete meta.stack;
delete meta.trace;
output += ' ' + exports.serialize(meta);
output += '\n' + stack.map(function(s){
return s + '\n';
});
} else {
output += ' ' + exports.serialize(meta);
}
}
}
Expand Down

0 comments on commit 50163a0

Please sign in to comment.