![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@ahmadnassri/debug
Advanced tools
Debugging utility using environment regex, matches node core's debugging technique
Debugging utility using environment regex, matches node core’s debugging technique
npm install @ahmadnassri/debug
Follows the exact same behaviour as util.debuglog
with some minor differences:
DEBUG
and NODE_DEBUG
environment variablesdebuglog()
is called (vs. on require
/ import
)debuglog()
is called)Option | Type | Description | Default |
---|---|---|---|
section | <string> | The section name | |
logger | <Function> | Custom logger function | console.debug |
pid | <boolean> | Include process id in output | true |
perf | <boolean> | Include performance time in output | false |
Returns:
<Function>
The logging function
The debuglog()
method is used to create a function that conditionally writes debug messages to stderr based on the existence of the DEBUG
or NODE_DEBUG
environment variables. If the section name appears within the value of that environment variable, then the returned function operates similar to console.debug()
. If not, then the returned function is a no-op.
Variable | Description |
---|---|
DEBUG | A comma-separated list of section names to enable |
NODE_DEBUG | A comma-separated list of section names to enable |
DEBUG_COLORS | Enable/disable colors in output (will also respect Node's NO_COLORS & NODE_DISABLE_COLORS ) |
DEBUG_PERF | Include/exclude performance time in output (⚠️ will overwrite perf option) |
DEBUG_PID | Include/exclude process id in output (⚠️ will overwrite pid option) |
const debuglog = require('@ahmadnassri/debug')
const debug = debuglog('foo')
debug('hello from foo [%d]', 123)
If this program is run with DEBUG=foo
or NODE_DEBUG=foo
in the environment, then it will output something like:
FOO 3245: hello from foo [123]
where 3245 is the process id. If it is not run with that environment variable set, then it will not print anything.
Multiple section
names may be specified in the environment variable, separated by commas, or spaces.
DEBUG=fs,net,tls
section
names in the environment variable, can also be a regex string:
const debuglog = require('@ahmadnassri/debug')
const primary = debuglog('foo:primary')
const secondary = debuglog('foo:secondary')
primary('primary logger')
secondary('secondary logger')
$ NODE_DEBUG=foo:.* node app.js
FOO:PRIMARY 28382 primary logger
FOO:SECONDARY 28382 secondary logger
$ DEBUG="(F|O)+:.*" node app.js
FOO:PRIMARY 28274 primary logger
FOO:SECONDARY 28274 secondary logger
const debuglog = require('@ahmadnassri/debug')
const debug = debuglog('foo', { pid: false })
debug('hello from foo [%d]', 123)
FOO: hello from foo [123]
const debuglog = require('@ahmadnassri/debug')
const debug = debuglog('foo', { perf: true })
debug('hello from foo [%d]', 123)
FOO 3245 (65ms) hello from foo [123] +0ms
$ DEBUG_COLORS=0 node app.js
$ DEBUG_PERF=0 node app.js
Author: Ahmad Nassri • Twitter: @AhmadNassri
FAQs
Debugging utility using environment regex, matches node core's debugging technique
We found that @ahmadnassri/debug demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.