-
Notifications
You must be signed in to change notification settings - Fork 43
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
feat: Logger with log levels #1672
Conversation
size-limit report 📦
|
this._warn = debug(Logger.createDebugNamespace("WARN", prefix)); | ||
this._error = debug(Logger.createDebugNamespace("ERROR", prefix)); | ||
|
||
this._info.log = console.info.bind(console); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing is better than good old console.*
😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this compatible with libp2p logging approach?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it isn't -- #1677 re-enables that functionality @fryorcraken
5ec0f58
to
176f2c0
Compare
* setup a custom Logger with log level support * refactor codebase for to use new Logger with log levels * disallow usage of `debug` directly / only allow usage in/through custom Logger * remove `debug` from logger
Problem
We currently use the native
debug
for all logging purposes.This is tricky -- while we want to add as many logs as possible to ensure smooth debugging, information travel, etc, we also don't want to limit readability & flood logs.
Solution
Allow usage of segregating logs by level:
log.info()
,log.warn()
-- this would enable library consumers to choose the log level they want to watch, help us add as many logs as possible based on the level.Notes
debug
andconsole
packages by creating a wrapper to allow of log levels and prefixes to keep things lightweight without adding dependency on a new packagedebug
package across the codebase directly, and only allow usage through theLogger
class