
Security News
Software Engineering Daily Podcast: Feross on AI, Open Source, and Supply Chain Risk
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.
debug-instanced
Advanced tools
Like the 'debug' module, but automatically labels output with an instance ID. Useful when dealing with many different objects.
Like the debug module, but automatically labels output with an instance ID. Useful when dealing with many different objects.
See also example.js in the package.
"use strict";
const debugInstanced = require("debug-instanced")("example");
function doThing() {
let debug = debugInstanced("foo");
debug("line one");
2 + 2;
debug("line two");
}
doThing();
doThing();
This would output the following:
~/projects/debug-instanced> DEBUG=* node example.js
example [e04ab8] created instance (type: foo) +0ms
example [e04ab8] line one +1ms
example [e04ab8] line two +0ms
example [931af6] created instance (type: foo) +0ms
example [931af6] line one +1ms
example [931af6] line two +1ms
As you can see, the output from each 'instance' of the call to doThing is labelled with its own unique ID, that is generated when debugInstanced is called.
The API is basically the same as that of debug, except there's an extra level of function invocation. Normally when you call the function exported by debug you immediately get a function that lets you log things; but in debug-instanced, that gets you an instance creation function instead. That instance creation function, when called, returns the logging function you need - and it's called the same way as the logging function in debug.
The enabled property is available on the instance creation function, instead of on the logging function where it would be in debug.
FAQs
Like the 'debug' module, but automatically labels output with an instance ID. Useful when dealing with many different objects.
We found that debug-instanced demonstrated a healthy version release cadence and project activity because the last version was released less than 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
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.

Security News
GitHub has revoked npm classic tokens for publishing; maintainers must migrate, but OpenJS warns OIDC trusted publishing still has risky gaps for critical projects.

Security News
Rust’s crates.io team is advancing an RFC to add a Security tab that surfaces RustSec vulnerability and unsoundness advisories directly on crate pages.