Closed
Description
Hey all, I have a NodeJS-application in which I'm trying to redirect the debug output from modules I require. Not sure if I'm doing something wrong or what I want is not possible, so I thought I'd ask.
My situation is as follows:
App => has a custom debug log I want to redirect the logs to
|-- Module A => logs debug messages with debug("namespace-a")(message...)
|-- Module B => logs debug messages with debug("namespace-b")(message...)
In the app, I am using the following code to replace the log function of the sub modules with my custom one:
process.env.DEBUG = "*";
const debugPackage = require("debug");
const debuggers = [debugPackage("namespace-a"), debugPackage("namespace-b")];
for (const d of debuggers) {
d.log = (str) => customLogFunction(str);
}
However I'm not getting any redirected logs. Am I missing something?
Metadata
Metadata
Assignees
Labels
No labels