Reputation: 123058
How do I use debug
? Reading the debug docs I get:
With debug you simply invoke the exported function to generate your debug function, passing it a name which will determine if a noop function is returned, or a decorated console.error, so all of the console format string goodies you're used to work fine.
Ok, the debug module exports a single function, I understand. But this part seems to be missing something:
"That function takes a name
which will determine if a noop function is returned, or a decorated console.error"
OK. I gather name
is a String, so what String value determines if a no-op is returned, or a decorated console.error? I would like the console error, as no-op seems to be the default.
I have a module that uses debug. It's currently set up like;
var debug = require('debug')('module-name');
And it's completely quiet. I would like debug to be be turned on. What String value should I use to enable debug?
Upvotes: 1
Views: 2945
Reputation: 145994
So debug
basically has an on-off switch but it's not in your javascript code, it's in the DEBUG
environment variable value. So if you wanted to turn on debugging for your sample snippet you would do:
In bash:
export DEBUG=module-name
node myapp.js
In powershell:
$env:DEBUG = 'module-name'
node myapp.js
Debugging is off by default, so if you unset DEBUG
in your shell, nothing will be output.
Upvotes: 5