Skip to content
Browse files
Document enable() (#517)
Document enable, and help to avoid pitfall of #425
  • Loading branch information
abenhamdine authored and TooTallNate committed Nov 8, 2017
1 parent 7116906 commit ab5083f68a7e4c1ab474ff06cd5995d706abf143
Showing 1 changed file with 35 additions and 0 deletions.
@@ -248,6 +248,41 @@ error('now goes to stdout via');
log('still goes to stdout, but via now');

## Set dynamically

You can also enable debug dynamically by calling the `enable()` method :

let debug = require('debug');
console.log(1, debug.enabled('test'));
console.log(2, debug.enabled('test'));
console.log(3, debug.enabled('test'));

print :
1 false
2 true
3 false

Usage :
`namespaces` can include modes separated by a colon and wildcards.

Note that calling `enable()` completely overrides previously set DEBUG variable :

$ DEBUG=foo node -e 'var dbg = require("debug"); dbg.enable("bar"); console.log(dbg.enabled("foo"))'
=> false

## Checking whether a debug target is enabled

After you've created a debug instance, you can determine whether or not it is

0 comments on commit ab5083f

Please sign in to comment.