You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The disable function should remove namespaces instead of trying to enable nothing
That's not the issue.
The disable()/enable() functions will only work on future created debug instances. This is because the debug code does not maintain a list of debug instances, since it would be a memory leak technically.
I'm considering a few ways to refactor the code to remedy this, but nothing concrete so far.
var debug = require("debug");
debug.enable("app:*");
var log1 = debug("app:log1");
log1("Should show");
debug.disable();
var log2 = debug("app:log2");
log2("Shouldn't show");
debug.enable("app:*");
var log3 = debug("app:log3");
log1("Should show");
log2("Shouldn't show");
log3("Should show");
One gets
app:log1 Should show +0ms
app:log2 Shouldn't show +2ms
app:log1 Should show +1ms
app:log2 Shouldn't show +0ms
app:log3 Should show +0ms
I understand what you mean by previous debug instances not being kept track of, but the disabling still does not work since enabling "" does not disable existing entries in exports.names.
app:log1 Should show +0ms
app:log2 Shouldn't show +2ms
app:log1 Should show +1ms
app:log2 Shouldn't show +0ms
app:log3 Should show +0ms
I understand what you mean by previous debug instances not being kept
track of, but the disabling still does not work since enabling "" does
not disable existing entries in exports.names.
—
Reply to this email directly or view it on GitHub #150 (comment).
null == '' returns false, so @CumpsD is right and this is a bug in the code. debug.disable() should call to exports.enable(null) rather than exports.enable('').
Anyhow, calling to exports.enable(null) will just disable the debug for future created debug instances (that is what this issue is about).
Activity
TooTallNate commentedon Oct 24, 2014
That's not the issue.
The
disable()/enable()functions will only work on future created debug instances. This is because the debug code does not maintain a list of debug instances, since it would be a memory leak technically.I'm considering a few ways to refactor the code to remedy this, but nothing concrete so far.
swook commentedon Oct 25, 2014
With
One gets
I understand what you mean by previous debug instances not being kept track of, but the disabling still does not work since enabling
""does not disable existing entries inexports.names.TooTallNate commentedon Oct 25, 2014
I see what you mean. Looks like
enable()should reset the names and skipsarrays. Patch welcome, otherwise I'll get to it eventually.
On Fri, Oct 24, 2014 at 5:09 PM, Seon-Wook Park notifications@github.com
wrote:
ibc commentedon Nov 16, 2014
+1
Verbosity fixes / Added hacks for reloading debug (see: debug-js/debu…
Fix debug-js#150
CumpsD commentedon Jul 2, 2015
debug.enable(null);does a real disable, removing the localStorage in the browser version, whiledebug.disable()simply sets it to an empty string.ibc commentedon Jul 2, 2015
null == ''returns false, so @CumpsD is right and this is a bug in the code.debug.disable()should call toexports.enable(null)rather thanexports.enable('').Anyhow, calling to
exports.enable(null)will just disable the debug for future created debug instances (that is what this issue is about).thebigredgeek commentedon Dec 14, 2016
#370 < V3 should solve this