• {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.

    1. const util = require('util');
    2. const enabled = util.debuglog('foo').enabled;
    3. if (enabled) {
    4. console.log('hello from foo [%d]', 123);
    5. }

    If this program is run with NODE_DEBUG=foo in the environment, then it will output something like:

    1. hello from foo [123]