Merge pull request #15 from TooTallNate/enabled

debug: add an `enabled` flag to the returned debug function
This commit is contained in:
TJ Holowaychuk 2012-03-16 14:56:58 -07:00
commit e7b895446c

View File

@ -105,17 +105,20 @@ function humanize(ms) {
*/
function debug(name) {
function disabled(){}
disabled.enabled = false;
var match = skips.some(function(re){
return re.test(name);
});
if (match) return function(){};
if (match) return disabled;
match = names.some(function(re){
return re.test(name);
});
if (!match) return function(){};
if (!match) return disabled;
var c = color();
function colored(fmt) {
@ -137,6 +140,8 @@ function debug(name) {
console.error.apply(this, arguments);
}
colored.enabled = plain.enabled = true;
return isatty
? colored
: plain;