Comparing version 0.1.0 to 0.2.0
0.2.0 / 2012-01-22 | ||
================== | ||
* Added wildcard support | ||
0.1.0 / 2011-12-02 | ||
@@ -3,0 +8,0 @@ ================== |
@@ -24,3 +24,3 @@ | ||
exports.version = '0.1.0'; | ||
exports.version = '0.2.0'; | ||
@@ -31,3 +31,8 @@ /** | ||
var names = (process.env.DEBUG || '').split(/[\s,]+/); | ||
var names = (process.env.DEBUG || '') | ||
.split(/[\s,]+/) | ||
.map(function(name){ | ||
name = name.replace('*', '.*?'); | ||
return new RegExp('^' + name + '$'); | ||
}); | ||
@@ -72,3 +77,7 @@ /** | ||
function debug(name) { | ||
if (!~names.indexOf(name)) return function(){}; | ||
var match = names.some(function(re){ | ||
return re.test(name); | ||
}); | ||
if (!match) return function(){}; | ||
var c = color(); | ||
@@ -75,0 +84,0 @@ |
{ | ||
"name": "debug" | ||
, "version": "0.1.0" | ||
, "version": "0.2.0" | ||
, "description": "small debugging utility" | ||
@@ -5,0 +5,0 @@ , "keywords": ["debug", "log", "debugger"] |
@@ -72,4 +72,8 @@ | ||
If you're using this in one or more of your libraries, you _should_ use the name of your library so that developers may toggle debugging as desired without guessing names. | ||
If you're using this in one or more of your libraries, you _should_ use the name of your library so that developers may toggle debugging as desired without guessing names. If you have more than one debuggers you _should_ prefix them with your library name and use ":" to separate features. For example "bodyParser" from Connect would then be "connect:bodyParser". | ||
## Wildcards | ||
The "*" character may be used as a wildcard. Suppose for example your library has debuggers named "connect:bodyParser", "connect:compress", "connect:session", instead of listing all three with `DEBUG=connect:bodyParser,connect.compress,connect:session`, you may simply do `DEBUG=connect:*`. | ||
## License | ||
@@ -76,0 +80,0 @@ |
6216
11
92
101