Skip to content

Commit

Permalink
[fix] Dont strip colors for every transport
Browse files Browse the repository at this point in the history
  • Loading branch information
indexzero committed Aug 22, 2011
1 parent 4a45c74 commit 415b41a
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions lib/winston/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,23 +127,22 @@ Logger.prototype.log = function (level, msg) {
return onError(new Error('Unknown log level: ' + level));
}

//
// For consideration of terminal 'color" programs like colors.js,
// which can add ANSI escape color codes to strings, we destyle the
// ANSI color escape codes when `this.stripColors` is set.
//
// see: http://en.wikipedia.org/wiki/ANSI_escape_code
//
if (this.stripColors) {
var code = /\u001b\[\d+m/g;
msg = ('' + msg).replace(code, '');
}

for (var i = 0, l = this._names.length; i < l; i++) {
var transport = this.transports[this._names[i]];
if ((transport.level && self.levels[transport.level] <= self.levels[level])
|| (!transport.level && self.levels[self.level] <= self.levels[level])) {

//
// For consideration of terminal 'color" programs like colors.js,
// which can add ANSI escape color codes to strings, we destyle the
// ANSI color escape codes when `this.stripColors` is set.
//
// see: http://en.wikipedia.org/wiki/ANSI_escape_code
//
if (this.stripColors) {
var code = /\u001b\[\d+m/g;
msg = ('' + msg).replace(code, '');
}

transport.log(level, msg, meta, function (err) {
self.emit('log', transport, level, msg, meta);
});
Expand Down

0 comments on commit 415b41a

Please sign in to comment.