Skip to content
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

[Feature] enable/disable debugging dynamically #433

Closed
geonanorch opened this issue Mar 14, 2017 · 5 comments
Closed

[Feature] enable/disable debugging dynamically #433

geonanorch opened this issue Mar 14, 2017 · 5 comments

Comments

@geonanorch
Copy link

Often when one is investigating a 'live' issue, one would rather not restart node to enable debugging: this might make the problem disappear until it is triggered again later. Instead debug configuration should be alterable dynamically through some kind of listener (e.g. file watch, socket –the implementation of the listener is not the purpose of this issue, though that would make a nice addition!).

Support for such dynamic changes would be easy to add in debug.js, here the output of diff -n for the current codebase:

a21 1
exports._debuggers = Object.create(null);
a126 1
  exports._debuggers[namespace] = debug;
a155 10
  for (const namespace in exports._debuggers) {
      exports._debuggers[namespace].enabled = false;
      exports.names.some( (pattern) => {
          const match = pattern.test(namespace);
          if (match) {
              exports._debuggers[namespace].enabled = true;
          }
          return match;
      });
  }

With above one can change the debug settings from any place in the code using the same values as passed through the DEBUG environment variable at initialization time:

const debugCore = require('debug');
debugCore.enable('mymod*');

See also issue #419 (and possibly #416 and #425).

@TooTallNate
Copy link
Contributor

Please try out v3.0.0, which includes bf88540.

@geonanorch
Copy link
Author

Thanks, will do! Initial feedback in the meantime:

  • unless I missed it in README.md, the feature is not documented
  • the feature is not listed under the release notes for 3.0.0

All the same, thank you for considering and implementing my request :-)

@Yalhu
Copy link

Yalhu commented Apr 12, 2018

I use debug via browserify-as-a-service build(version 3.1.0) and set localStorage. What should I do to disable debug when publish on line?
localStorage.removeItem('debug') works weird when there is a iframe ,which is also have debug. my case:#559

@tasoss
Copy link

tasoss commented Aug 21, 2020

Is it possible to do something like that by for example re-exporting debug env. variable ?
I mean to dynamically change the modules but not insides js code but from an env. variable?
Thanks@

@Qix-
Copy link
Member

Qix- commented Aug 21, 2020

@tasoss No, as that is a limitation of the operating system. You cannot change an environment variable from outside a process.

@debug-js debug-js locked as off-topic and limited conversation to collaborators Aug 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

5 participants