diff --git a/README.md b/README.md index 48dd9235..1e597d7d 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ Then, run the program to be debugged as usual. ## Conventions - 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". + 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". If you append a "*" to the end of your name, it will always be enabled regardless of the setting of the DEBUG environment variable. You can then use it for normal output as well as debug output. ## Wildcards diff --git a/src/debug.js b/src/debug.js index 4d3c7f27..6d716187 100644 --- a/src/debug.js +++ b/src/debug.js @@ -28,12 +28,6 @@ exports.skips = []; exports.formatters = {}; -/** - * Previous log timestamp. - */ - -var prevTime; - /** * Select a color. * @param {String} namespace @@ -62,6 +56,8 @@ function selectColor(namespace) { function createDebug(namespace) { + var prevTime; + function debug() { // disabled? if (!debug.enabled) return; @@ -171,6 +167,9 @@ function disable() { */ function enabled(name) { + if (name[name.length - 1] === '*') { + return true; + } var i, len; for (i = 0, len = exports.skips.length; i < len; i++) { if (exports.skips[i].test(name)) {