-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
Eliminate high coupling to debug
#3702
Comments
First, thanks for your efforts on this subject! Are you referring to the browser bundle (socket.io-client), or do you think it should also apply to the server? Note: the |
Hi @darrachequesne , thanks for taking this into consideration! Basically I am referring to both the browser bundle and the server bundle. Yeah stripping away But I like you to consider how great it would be for app developers if they could be the one to select the logging framework for their app and simply have socketio respect that choice. Not only in production but also (and maybe especially) during development. Those developers that prefer debug would npm install --save socket.io anylogger debug anylogger-debug and in their entry point require('anylogger-debug') Those developers that instead prefer npm install --save socket.io anylogger loglevel anylogger-loglevel and require('anylogger-loglevel') It is this flexibility, achieved by decoupling libraries from specific logging frameworks, that is |
I created some issues and PRs because I wanted to make a PR to change from debug to anylogger for you to check it out, but I first wanted to update the dependencies of this project but ran into some issues with that and got sidetracked. But maybe it's good. Now you can check some of my contributions and merge them if you feel they are useful and if this all goes well we can maybe discuss this issue after that. |
@darrachequesne |
I don't think that we will merge this. Note: we could also move to Node.js built-in |
You want to:
Implementation
I'd be willing to create a PR for this feature.
Subject of the feature
Reduce coupling and footprint of minified file by using
anylogger
i.s.odebug
Problem
Currently, this library has a dependency on
debug
. Though that is an excellent library, this dependency has 2 major drawbacks: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 libraryAlternatives
Please have a look at
anylogger
. It's a logging facade specifically designed for libraries. It achieves these goals: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 reduced 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 installdebug
as a dev-dependency and thenrequire('anylogger-debug')
in your tests to have your tests work exactly as they always did, withdebug
as the logging framework, while still decoupling it fromdebug
for all clients.The text was updated successfully, but these errors were encountered: