Skip to content

Commit

Permalink
human readable uncaught exception as option
Browse files Browse the repository at this point in the history
  • Loading branch information
samzilverberg authored and indexzero committed Feb 3, 2015
1 parent 50163a0 commit 91a1e90
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 12 deletions.
17 changes: 9 additions & 8 deletions lib/winston/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,12 +224,13 @@ exports.log = function (options) {
} else if (options.prettyPrint) {
output += ' ' + '\n' + util.inspect(meta, false, options.depth || null, options.colorize);
} else if (
Object.keys(meta).length === 5
&& meta.hasOwnProperty('date')
&& meta.hasOwnProperty('process')
&& meta.hasOwnProperty('os')
&& meta.hasOwnProperty('trace')
&& meta.hasOwnProperty('stack')) {
options.humanReadableUnhandledException
&& 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
Expand All @@ -238,11 +239,11 @@ exports.log = function (options) {
delete meta.stack;
delete meta.trace;
output += ' ' + exports.serialize(meta);
output += '\n' + stack.map(function(s){
output += '\n' + stack.map(function (s) {
return s + '\n';
});
} else {
output += ' ' + exports.serialize(meta);
output += ' ' + exports.serialize(meta);
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion lib/winston/transports/console.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ Console.prototype.log = function (level, msg, meta, callback) {
label: this.label,
logstash: this.logstash,
depth: this.depth,
formatter: this.formatter
formatter: this.formatter,
humanReadableUnhandledException: this.humanReadableUnhandledException
});

if (level === 'error' || (level === 'debug' && !this.debugStdout) ) {
Expand Down
3 changes: 2 additions & 1 deletion lib/winston/transports/daily-rotate-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ DailyRotateFile.prototype.log = function (level, msg, meta, callback) {
stringify: this.stringify,
showLevel: this.showLevel,
depth: this.depth,
formatter: this.formatter
formatter: this.formatter,
humanReadableUnhandledException: this.humanReadableUnhandledException
}) + '\n';

this._size += output.length;
Expand Down
3 changes: 2 additions & 1 deletion lib/winston/transports/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ File.prototype.log = function (level, msg, meta, callback) {
stringify: this.stringify,
label: this.label,
depth: this.depth,
formatter: this.formatter
formatter: this.formatter,
humanReadableUnhandledException: this.humanReadableUnhandledException
}) + this.eol;


Expand Down
3 changes: 2 additions & 1 deletion lib/winston/transports/memory.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ Memory.prototype.log = function (level, msg, meta, callback) {
raw: this.raw,
label: this.label,
depth: this.depth,
formatter: this.formatter
formatter: this.formatter,
humanReadableUnhandledException: this.humanReadableUnhandledException
});

if (level === 'error' || level === 'debug') {
Expand Down
1 change: 1 addition & 0 deletions lib/winston/transports/transport.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ var Transport = exports.Transport = function (options) {

this.handleExceptions = options.handleExceptions || false;
this.exceptionsLevel = options.exceptionsLevel || 'error';
this.humanReadableUnhandledException = options.humanReadableUnhandledException || false;
};

//
Expand Down

0 comments on commit 91a1e90

Please sign in to comment.