
Security News
AGENTS.md Gains Traction as an Open Format for AI Coding Agents
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
@bmacnaughton/debug-custom
Advanced tools
A thin wrapper on the debug logging package that allows levels to appear customized for your package.
I didn't like to enter prefix:level
where prefix
was required to prevent name conflicts because multiple packages might be using the debug
package. debug-custom
is a thin wrapper around debug
that allows the user to hide whatever prefix is used to prevent conflicts. debug-custom also makes it easier to add and remove debug levels dynamically under program control.
Using debug
the package prefix must be repeated for each log level:
export DEBUG=my-app:error,my-app:warn,my-app:info
and, in code:
const debug = require('debug')
const logError = debug('my-app:error')
const logWarn = debug('my-app:warn')
const logInfo = debug('my-app:info')
Using debug-custom
the package prefix is invisible:
export MYAPP=error,warn,info
in code,
const DebugCustom = require ('debug-custom')
// specify the prefix and options, default enabled settings are 'error,warn'.
const logger = new DebugCustom('my-app', {defaultLevels: process.env.MYAPP_LOG_SETTINGS})
const logError = logger.make('error')
const logWarn = logger.make('warn')
const logInfo = logger.make('info')
And, if you want to enable or disable levels via API, just use
logger.addEnabled('debug')
logger.removeEnabled('info')
If you want to set absolutely (not adding or removing)
const previous = logger.logLevel
logger.logLevel = 'error'
// do some stuff
logger.logLevel = previous
You can also set logLevel
to an array if you want.
If you need access to the instance of debug
used it's available as logger.debug
. This can come in handy for testing.
The prefix used to instantiate the CustomDebug
class should not conflict with other packages using debug
, so try to make yours unique. You won't see it unless you look at the DEBUG environment variable.
FAQs
A thin wrapper around the debug logging package
The npm package @bmacnaughton/debug-custom receives a total of 0 weekly downloads. As such, @bmacnaughton/debug-custom popularity was classified as not popular.
We found that @bmacnaughton/debug-custom demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.