Skip to content

Commit

Permalink
[fix] Correct listeners in logException. Fixes #218 #213 #327.
Browse files Browse the repository at this point in the history
  • Loading branch information
indexzero committed Sep 25, 2015
1 parent 87b97cc commit 44564de
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions lib/winston/transports/transport.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,19 +113,23 @@ Transport.prototype.formatResults = function (results, options) {
// all logging has completed.
//
Transport.prototype.logException = function (msg, meta, callback) {
var self = this;
var self = this,
called;

function onLogged () {
self.removeListener('error', onError);
callback();
if (this.silent) {
return callback();
}

function onError () {
self.removeListener('logged', onLogged);
callback();
function onComplete () {
if (!called) {
called = true;
self.removeListener('logged', onComplete);
self.removeListener('error', onComplete);
callback();
}
}

this.once('logged', onLogged);
this.once('error', onError);
this.once('logged', onComplete);
this.once('error', onComplete);
this.log(self.exceptionsLevel, msg, meta, function () { });
};

0 comments on commit 44564de

Please sign in to comment.