Skip to content

Commit 91a1e90

Browse files
samzilverbergindexzero
authored andcommitted
human readable uncaught exception as option
1 parent 50163a0 commit 91a1e90

File tree

6 files changed

+18
-12
lines changed

6 files changed

+18
-12
lines changed

lib/winston/common.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -224,12 +224,13 @@ exports.log = function (options) {
224224
} else if (options.prettyPrint) {
225225
output += ' ' + '\n' + util.inspect(meta, false, options.depth || null, options.colorize);
226226
} else if (
227-
Object.keys(meta).length === 5
228-
&& meta.hasOwnProperty('date')
229-
&& meta.hasOwnProperty('process')
230-
&& meta.hasOwnProperty('os')
231-
&& meta.hasOwnProperty('trace')
232-
&& meta.hasOwnProperty('stack')) {
227+
options.humanReadableUnhandledException
228+
&& Object.keys(meta).length === 5
229+
&& meta.hasOwnProperty('date')
230+
&& meta.hasOwnProperty('process')
231+
&& meta.hasOwnProperty('os')
232+
&& meta.hasOwnProperty('trace')
233+
&& meta.hasOwnProperty('stack')) {
233234

234235
//
235236
// If meta carries unhandled exception data serialize the stack nicely
@@ -238,11 +239,11 @@ exports.log = function (options) {
238239
delete meta.stack;
239240
delete meta.trace;
240241
output += ' ' + exports.serialize(meta);
241-
output += '\n' + stack.map(function(s){
242+
output += '\n' + stack.map(function (s) {
242243
return s + '\n';
243244
});
244245
} else {
245-
output += ' ' + exports.serialize(meta);
246+
output += ' ' + exports.serialize(meta);
246247
}
247248
}
248249
}

lib/winston/transports/console.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ Console.prototype.log = function (level, msg, meta, callback) {
7878
label: this.label,
7979
logstash: this.logstash,
8080
depth: this.depth,
81-
formatter: this.formatter
81+
formatter: this.formatter,
82+
humanReadableUnhandledException: this.humanReadableUnhandledException
8283
});
8384

8485
if (level === 'error' || (level === 'debug' && !this.debugStdout) ) {

lib/winston/transports/daily-rotate-file.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,8 @@ DailyRotateFile.prototype.log = function (level, msg, meta, callback) {
161161
stringify: this.stringify,
162162
showLevel: this.showLevel,
163163
depth: this.depth,
164-
formatter: this.formatter
164+
formatter: this.formatter,
165+
humanReadableUnhandledException: this.humanReadableUnhandledException
165166
}) + '\n';
166167

167168
this._size += output.length;

lib/winston/transports/file.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ File.prototype.log = function (level, msg, meta, callback) {
138138
stringify: this.stringify,
139139
label: this.label,
140140
depth: this.depth,
141-
formatter: this.formatter
141+
formatter: this.formatter,
142+
humanReadableUnhandledException: this.humanReadableUnhandledException
142143
}) + this.eol;
143144

144145

lib/winston/transports/memory.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ Memory.prototype.log = function (level, msg, meta, callback) {
7070
raw: this.raw,
7171
label: this.label,
7272
depth: this.depth,
73-
formatter: this.formatter
73+
formatter: this.formatter,
74+
humanReadableUnhandledException: this.humanReadableUnhandledException
7475
});
7576

7677
if (level === 'error' || level === 'debug') {

lib/winston/transports/transport.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ var Transport = exports.Transport = function (options) {
2727

2828
this.handleExceptions = options.handleExceptions || false;
2929
this.exceptionsLevel = options.exceptionsLevel || 'error';
30+
this.humanReadableUnhandledException = options.humanReadableUnhandledException || false;
3031
};
3132

3233
//

0 commit comments

Comments
 (0)