Skip to content

Commit

Permalink
added a method to clear transports
Browse files Browse the repository at this point in the history
  • Loading branch information
seejohnrun authored and indexzero committed Feb 22, 2012
1 parent f4609e6 commit ccc3e2e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/winston/logger.js
Expand Up @@ -309,6 +309,17 @@ Logger.prototype.addRewriter = function(rewriter) {
this.rewriters.push(rewriter);
}

//
// ### function clear ()
// Remove all transports from this instance
//
Logger.prototype.clear = function () {
for (var name in this.transports) {
console.log(name);
this.remove({ name: name });
}
};

//
// ### function remove (transport)
// #### @transport {Transport} Transport to remove.
Expand Down
15 changes: 15 additions & 0 deletions test/logger-test.js
Expand Up @@ -181,4 +181,19 @@ vows.describe('winton/logger').addBatch({
}
}
}
}).addBatch({
"The winston logger": {
topic: new (winston.Logger)({
transports: [
new (winston.transports.Console)(),
new (winston.transports.File)({ filename: path.join(__dirname, 'fixtures', 'logs', 'filelog.log' )})
]
}),
"the clear() method": {
"should remove all transports": function (logger) {
logger.clear();
assert.equal(helpers.size(logger.transports), 0);
}
}
}
}).export(module);

0 comments on commit ccc3e2e

Please sign in to comment.