diff --git a/lib/debug.js b/lib/debug.js index 1be8b66..1383f5f 100644 --- a/lib/debug.js +++ b/lib/debug.js @@ -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;