File tree 1 file changed +35
-0
lines changed
1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -248,6 +248,41 @@ error('now goes to stdout via console.info');
248
248
log (' still goes to stdout, but via console.info now' );
249
249
```
250
250
251
+ ## Set dynamically
252
+
253
+ You can also enable debug dynamically by calling the ` enable() ` method :
254
+
255
+ ``` js
256
+ let debug = require (' debug' );
257
+
258
+ console .log (1 , debug .enabled (' test' ));
259
+
260
+ debug .enable (' test' );
261
+ console .log (2 , debug .enabled (' test' ));
262
+
263
+ debug .disable ();
264
+ console .log (3 , debug .enabled (' test' ));
265
+
266
+ ```
267
+
268
+ print :
269
+ ```
270
+ 1 false
271
+ 2 true
272
+ 3 false
273
+ ```
274
+
275
+ Usage :
276
+ ` enable(namespaces) `
277
+ ` namespaces ` can include modes separated by a colon and wildcards.
278
+
279
+ Note that calling ` enable() ` completely overrides previously set DEBUG variable :
280
+
281
+ ```
282
+ $ DEBUG=foo node -e 'var dbg = require("debug"); dbg.enable("bar"); console.log(dbg.enabled("foo"))'
283
+ => false
284
+ ```
285
+
251
286
## Checking whether a debug target is enabled
252
287
253
288
After you've created a debug instance, you can determine whether or not it is
You can’t perform that action at this time.
0 commit comments