Skip to content

Commit

Permalink
Document enable() (#517)
Browse files Browse the repository at this point in the history
Document enable, and help to avoid pitfall of #425
  • Loading branch information
abenhamdine authored and TooTallNate committed Nov 8, 2017
1 parent 7116906 commit ab5083f
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,41 @@ error('now goes to stdout via console.info');
log('still goes to stdout, but via console.info now');
```

## Set dynamically

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

```js
let debug = require('debug');

console.log(1, debug.enabled('test'));

debug.enable('test');
console.log(2, debug.enabled('test'));

debug.disable();
console.log(3, debug.enabled('test'));

```

print :
```
1 false
2 true
3 false
```

Usage :
`enable(namespaces)`
`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
Expand Down

0 comments on commit ab5083f

Please sign in to comment.