-
Notifications
You must be signed in to change notification settings - Fork 934
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Question] Enable/disable on runtime for Node.js #419
Comments
I'm not sure if I understood your question. But you could modify the env. variable in the code e.g. If you listen for console inputs than you could modify it from your console:
|
I think that this wont be enough, because the logging mechanism is initialized on first require with environment variable DEBUG. Lets say I want to modify the namespace on different HTTP-Requests within my routes, when a special header value was set: Request-Header: function getSomething(req, res) {
process.env.DEBUG = req.headers["x-some-debug"];
// log everything with express* and error*
// ...
process.env.DEBUG = "";
// restore anything to default after request finished..
res.send("Hello!");
} Assignment to |
The work around you can try is to clean require cache? P.s. if you take a look at source code https://github.com/visionmedia/debug/blob/master/src/node.js#L241 |
@DoumanAsh: might work, but no solution for me.. thank you anyway. |
@moehlone I linked in my PS how debug inits logging on first import. |
@moehlone it sounds like we have similar needs: I want to be able to dynamically (through some kind of listener, e.g. file watching or socket) change the debug settings.
you can then alter dynamically debug settings by passing the same value as in the
For listeners I am thinking to use file watching, found an example with pinojs/pino-arborsculpture And by the way I recommend pinojs/pino-debug, it is compatible wiith debug (including the change I described above) and reportedly much faster. I have raised issue #433 in the hope to get the above code change (or similar) integrated. |
@geonanorch thank you - this is what we thought about. I think #433 is enough and we can close this one. |
Enable/Disable Dynamically runtime easily using https://gist.github.com/manjeshpv/106dc2e05d4b9f252dc9f3f41afccb59 |
Hi,
is there a way to enable or disable debugging for modules on runtime (Node.js)?
Best regards
Philipp
The text was updated successfully, but these errors were encountered: