diff --git a/README.md b/README.md index 441cbecd..3748db94 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,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 6a5e3fc9..ee31a398 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; @@ -174,6 +170,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)) {