Skip to content

Commit

Permalink
[refactor] Simply the initialization logic for exception handling.
Browse files Browse the repository at this point in the history
[breaking] No longer respect the `handleExceptions` option to `new winston.Logger`. Instead
just pass in the `exceptionHandlers` option itself.
  • Loading branch information
indexzero committed Oct 29, 2015
1 parent f0edafd commit a470ab5
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions lib/winston/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,7 @@ var Logger = exports.Logger = function (options) {
}

if (options.exceptionHandlers) {
handleExceptions = true;
options.exceptionHandlers.forEach(function (handler) {
self._hnames.push(handler.name);
self.exceptionHandlers[handler.name] = handler;
});
}

if (options.handleExceptions || handleExceptions) {
this.handleExceptions();
this.handleExceptions(options.exceptionHandlers);
}
};

Expand Down Expand Up @@ -377,8 +369,9 @@ Logger.prototype.close = function () {
};

//
// ### function handleExceptions ()
// Handles `uncaughtException` events for the current process
// ### function handleExceptions ([tr0, tr1...] || tr0, tr1, ...)
// Handles `uncaughtException` events for the current process by
// ADDING any handlers passed in.
//
Logger.prototype.handleExceptions = function () {
var args = Array.prototype.slice.call(arguments),
Expand All @@ -394,6 +387,7 @@ Logger.prototype.handleExceptions = function () {
}
});

this.exceptionHandlers = this.exceptionHandlers || {};
handlers.forEach(function (handler) {
self.exceptionHandlers[handler.name] = handler;
});
Expand Down

0 comments on commit a470ab5

Please sign in to comment.