Skip to content

Commit a470ab5

Browse files
committed
[refactor] Simply the initialization logic for exception handling.
[breaking] No longer respect the `handleExceptions` option to `new winston.Logger`. Instead just pass in the `exceptionHandlers` option itself.
1 parent f0edafd commit a470ab5

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

lib/winston/logger.js

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,7 @@ var Logger = exports.Logger = function (options) {
7272
}
7373

7474
if (options.exceptionHandlers) {
75-
handleExceptions = true;
76-
options.exceptionHandlers.forEach(function (handler) {
77-
self._hnames.push(handler.name);
78-
self.exceptionHandlers[handler.name] = handler;
79-
});
80-
}
81-
82-
if (options.handleExceptions || handleExceptions) {
83-
this.handleExceptions();
75+
this.handleExceptions(options.exceptionHandlers);
8476
}
8577
};
8678

@@ -377,8 +369,9 @@ Logger.prototype.close = function () {
377369
};
378370

379371
//
380-
// ### function handleExceptions ()
381-
// Handles `uncaughtException` events for the current process
372+
// ### function handleExceptions ([tr0, tr1...] || tr0, tr1, ...)
373+
// Handles `uncaughtException` events for the current process by
374+
// ADDING any handlers passed in.
382375
//
383376
Logger.prototype.handleExceptions = function () {
384377
var args = Array.prototype.slice.call(arguments),
@@ -394,6 +387,7 @@ Logger.prototype.handleExceptions = function () {
394387
}
395388
});
396389

390+
this.exceptionHandlers = this.exceptionHandlers || {};
397391
handlers.forEach(function (handler) {
398392
self.exceptionHandlers[handler.name] = handler;
399393
});

0 commit comments

Comments
 (0)