interface
util.DebugLogger
interface DebugLogger
- enabled: boolean
The
util.debuglog().enabledgetter is used to create a test that can be used in conditionals based on the existence of theNODE_DEBUGenvironment variable. If thesectionname appears within the value of that environment variable, then the returned value will betrue. If not, then the returned value will befalse.import { debuglog } from 'node:util'; const enabled = debuglog('foo').enabled; if (enabled) { console.log('hello from foo [%d]', 123); }If this program is run with
NODE_DEBUG=fooin the environment, then it will output something like:hello from foo [123]