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 request: attach custom formatters only to a given namespace (packages that use debug could clobber each others' custom formatters...) #804

Closed
jedwards1211 opened this issue Dec 21, 2020 · 2 comments

Comments

@jedwards1211
Copy link

jedwards1211 commented Dec 21, 2020

I'd like to use custom formatters in a package I'm writing, but since the formatters live on the global debug module, they could interfere with other packages that use the same module.

Wouldn't it be better if we could attach the formatters to a specific debugger created by require('debug')('myNamespace') rather than on require('debug') itself?

@jedwards1211 jedwards1211 changed the title Feature request: apply formatters only to a given namespace (packages that use debug could clobber each others' formatters...) Feature request: attach custom formatters only to a given namespace (packages that use debug could clobber each others' custom formatters...) Dec 21, 2020
@Qix-
Copy link
Member

Qix- commented Dec 21, 2020

Not really, because debug is a debugging library, not a logging library. Lightweight code and uniformity are kind of preferred in such cases. Also, this is very much an edge case and I suspect a more proprietary solution would do you better than trying to hack on a fix to a library that really isn't built for it.

That being said, #556 is would solve your problem and is officially planned (when it will actually happen is a good question, though).

Going to close it as a duplicate for that reason :) Thanks for the suggestion though!

@Qix- Qix- closed this as completed Dec 21, 2020
@jedwards1211
Copy link
Author

jedwards1211 commented Dec 22, 2020

I guess as long as I only register formatters in my test code, it won't cause any problem in production, even though there will be more arguments than format tokens without the custom formatters registered.

Ironically my org has its own logging lib that's a bit more flexible, I'm just not in the habit of using it for public projects 🙃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants