Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make millisecond timer namespace specific and allow 'always enabled' output #408

Merged
merged 2 commits into from Jan 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -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

Expand Down
11 changes: 5 additions & 6 deletions src/debug.js
Expand Up @@ -28,12 +28,6 @@ exports.skips = [];

exports.formatters = {};

/**
* Previous log timestamp.
*/

var prevTime;

/**
* Select a color.
* @param {String} namespace
Expand Down Expand Up @@ -62,6 +56,8 @@ function selectColor(namespace) {

function createDebug(namespace) {

var prevTime;

function debug() {
// disabled?
if (!debug.enabled) return;
Expand Down Expand Up @@ -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)) {
Expand Down