- {boolean}
The util.debuglog().enabled
getter is used to create a test that can be used
in conditionals based on the existence of the NODE_DEBUG
environment variable.
If the section
name appears within the value of that environment variable,
then the returned value will be true
. If not, then the returned value will be
false
.
const util = require('util');
const enabled = util.debuglog('foo').enabled;
if (enabled) {
console.log('hello from foo [%d]', 123);
}
If this program is run with NODE_DEBUG=foo
in the environment, then it will
output something like:
hello from foo [123]