Name |
Date |
Size |
#Lines |
LOC |
||
---|---|---|---|---|---|---|
.. | - | - | ||||
LICENSE | D | 12-May-2024 | 1.1 KiB | 20 | 16 | |
README.md | D | 12-May-2024 | 1.3 KiB | 41 | 27 | |
debuglog.js | D | 12-May-2024 | 554 | 23 | 19 | |
package.json | D | 12-May-2024 | 1.3 KiB | 57 | 56 |
README.md
1# debuglog - backport of util.debuglog() from node v0.11 2 3To facilitate using the `util.debuglog()` function that will be available when 4node v0.12 is released now, this is a copy extracted from the source. 5 6## require('debuglog') 7 8Return `util.debuglog`, if it exists, otherwise it will return an internal copy 9of the implementation from node v0.11. 10 11## debuglog(section) 12 13* `section` {String} The section of the program to be debugged 14* Returns: {Function} The logging function 15 16This is used to create a function which conditionally writes to stderr 17based on the existence of a `NODE_DEBUG` environment variable. If the 18`section` name appears in that environment variable, then the returned 19function will be similar to `console.error()`. If not, then the 20returned function is a no-op. 21 22For example: 23 24```javascript 25var debuglog = util.debuglog('foo'); 26 27var bar = 123; 28debuglog('hello from foo [%d]', bar); 29``` 30 31If this program is run with `NODE_DEBUG=foo` in the environment, then 32it will output something like: 33 34 FOO 3245: hello from foo [123] 35 36where `3245` is the process id. If it is not run with that 37environment variable set, then it will not print anything. 38 39You may separate multiple `NODE_DEBUG` environment variables with a 40comma. For example, `NODE_DEBUG=fs,net,tls`. 41