Decouple eslint from debug
See original GitHub issueThe version of ESLint you are using. Latest
The problem you want to solve.
Eliminate high coupling to debug
Your take on the correct solution to problem. Implement logging via a facade
Are you willing to submit a pull request to implement this change? Yes
Subject of the feature
Reduce coupling and footprint of minified file by using anylogger
i.s.o debug
Problem
Currently, this library has a dependency on debug
. Though that is an excellent library, this dependency has 2 major drawbacks:
- This library is now forcing
debug
onto all developers that use this library (high coupling) debug
is 3.1kB minified and gzipped, directly adding 3.1kB to the minimum footprint of this library
Alternatives
Please have a look at anylogger
. It’s a logging facade specifically designed for libraries. It achieves these goals:
- Decouple the library from the underlying logging framework
- Reduce the minimal bundle footprint. Anylogger is only 370 bytes.
The decoupling is achieved by only including the minimal facade to allow client code to do logging and using adapters to back that facade with an actual logging framework. The minimal footprint follows naturally from this decoupling as the bulk of the code lives in the adapter or logging library.
There are already adapters for some popular logging frameworks and more adapters can easily be created:
anylogger-console
(to use the console i.s.o some logging framework)anylogger-debug
anylogger-loglevel
anylogger-log4js
ulog
(logger with native anylogger support)
If this library were to switch to anylogger
, you could still install debug
as a dev-dependency and then require('anylogger-debug')
in your tests to have your tests work exactly as they always did, with debug
as the logging framework, while still decoupling it from debug
for all clients.
Disclaimer:
anylogger
was written by me so I’m self-advertising here. However I do honestly believe it is the best solution in this situation andanylogger
was written specifically to decrease coupling between libraries and logging frameworks because for any large application, devs typically end up with multiple loggers in their application because some libraries depend ondebug
, others onloglevel
, yet others onlog4js
and so on. This hurts bundle size badly as we add multiple kB of logging libraries to it.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
Thanks for the discussion. We won’t be moving forward with this, so closing.
@btmills Thank you, much appreciated! And yes I see why you don’t want to fix something that isn’t broken 😃