Skip to content

Commit

Permalink
Tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
mixu committed Jun 26, 2013
1 parent 23bb5dc commit fd63430
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/common/filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var levelMap = { debug: 1, info: 2, warn: 3, error: 4 };

function Filter() {
this.enabled = true;
this.undecidedIsTrue = true;
this.defaultResult = true;
this.clear();
}

Expand Down Expand Up @@ -44,7 +44,7 @@ Filter.prototype.test = function(name, level) {
return false;
}
}
return this.undecidedIsTrue;
return this.defaultResult;
};

Filter.prototype.write = function(name, level, args) {
Expand Down
1 change: 1 addition & 0 deletions lib/common/minilog.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ exports.end = exports.unpipe = exports.disable = function(from) {
return log.unpipe(from);
};

exports.Transform = Transform;
exports.Filter = Filter;
// this is the default filter that's applied when .enable() is called normally
// you can bypass it completely and set up your own pipes
Expand Down
4 changes: 3 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ var consoleLogger = require('./node/console.js');
// intercept the pipe method and transparently wrap the stringifier, if the
// destination is a Node core stream

module.exports.Stringifier = require('./node/stringify.js');

var oldPipe = module.exports.pipe;
module.exports.pipe = function(dest) {
if(dest instanceof require('stream')) {
return oldPipe.call(module.exports, new (require('./node/stringify.js'))).pipe(dest);
return oldPipe.call(module.exports, new (module.exports.Stringifier)).pipe(dest);
} else {
return oldPipe.call(module.exports, dest);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/node/formatters/minilog.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ FormatMinilog.prototype.write = function(name, level, args) {
this.emit('item', (name ? style(name +' ', 'grey') : '')
+ (level ? style(level, colors[level]) + ' ' : '')
+ args.map(function(item) {
return (typeof item == 'string' ? item : util.inspect(item, null, 20, true));
return (typeof item == 'string' ? item : util.inspect(item, null, 3, true));
}).join(' '));
};

Expand Down
2 changes: 1 addition & 1 deletion test/filter.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function filter(name, level) {
function enable(str) {
f.clear();
// whitelisted only mode
f.undecidedIsTrue = false;
f.defaultResult = false;

var parts = (str || '*.debug').split(/[\s,]+/), i, expr;
for(i = 0; i < parts.length; i++) {
Expand Down

0 comments on commit fd63430

Please sign in to comment.