Skip to content

enable() invalidates created loggers that should be enabled #533

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
turnerhayes opened this issue Dec 11, 2017 · 5 comments
Closed

enable() invalidates created loggers that should be enabled #533

turnerhayes opened this issue Dec 11, 2017 · 5 comments
Labels
bug This issue identifies a malfunction help-wanted This issue has an actionable item

Comments

@turnerhayes
Copy link

For example, let's say I have the following:

const debug = require("debug");
const foobarDebug = debug("foo:bar");

debug.enable("foo:*");

console.log("debug.enabled('foo:bar')?", debug.enabled("foo:bar"));
console.log("foobarDebug enabled?", foobarDebug.enabled);

will output

debug.enabled('foo:bar')? true
foobarDebug enabled? false

If you create the debugger after calling enable() it works as expected. I understand that enable() overrides what was previously enabled, but I would expect that anything that passes the new filters would be enabled.

@Qix- Qix- added feature This proposes or provides a feature or enhancement question This issue asks a question or requests usage support discussion This issue is requesting comments and discussion labels Jun 20, 2018
@Qix- Qix- added bug This issue identifies a malfunction and removed discussion This issue is requesting comments and discussion feature This proposes or provides a feature or enhancement question This issue asks a question or requests usage support labels Sep 11, 2018
@Qix-
Copy link
Member

Qix- commented Sep 11, 2018

Agreed, this needs to be fixed.

@Qix- Qix- added the help-wanted This issue has an actionable item label Sep 11, 2018
@mblarsen
Copy link
Contributor

mblarsen commented Oct 6, 2018

I tried adding this unit test and the issue seems to be resolved. But perhaps I misunderstood the issue.

	describe('issues', () => {
		it('#533: set enabled after creating instance', () => {
			const fooBar = debug('foo:bar');
			expect(fooBar.enabled).to.be.equal(false);
			debug.enable('foo:*');
			expect(debug.enabled('foo:bar')).to.be.equal(true);
			expect(fooBar.enabled).to.be.equal(true);
		});
	});

@Qix-
Copy link
Member

Qix- commented Oct 7, 2018

You did. Try this:

debug.enable('foo:*');
debug('foo:bar').enabled // => true

debug.enable('bar:*');
debug('bar:foo').enabled // => true
debug('foo:bar').enabled // => false :(

@mblarsen
Copy link
Contributor

mblarsen commented Oct 7, 2018

Yes, that is the #425 issue.

In this issue, however, the namespace enable is called with a namespace string that matches an existing instance.

Same cause different problem perhaps.

@Qix-
Copy link
Member

Qix- commented Dec 18, 2018

Closing in favor of #425. I'm moving the whole .enable()/.disable() renovations there.

@Qix- Qix- closed this as completed Dec 18, 2018
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug This issue identifies a malfunction help-wanted This issue has an actionable item
Development

No branches or pull requests

3 participants