-
Notifications
You must be signed in to change notification settings - Fork 585
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
Improve default logger for realm/react #5698
Conversation
The defaul tlogger could be a bit smarter. This will print a contextual log message with the level and use either `console.error`, `console.warn` and `console.log` based on the relevant level. This also sets a default log level to WARN.
Why not add this to the |
I've wanted to do this for a while, so I have no argument against not doing it directly. |
I see. If @papafe is already solving this for v12 with the unified logger, (btw, what issue is is tracking that?), I'd suggest holding back on this, as we want to be sure loading @realm/react won't override the default he'll be implementing, right? |
The unified logger will be at a different entry point and this would turn into a no-op. So this will just be backwards compatible. I want to still ensure v11 users get the advantages of the
|
As I read the last comment on the unified logger issue, the |
@kraenhansen How would you recommend we support both versions of logging? With this change, users wouldn't even have to update
This will be a breaking change then right? We should probably make unified logging a v13 change if |
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.
My comment is only minor (mostly enhancing readability) and can be ignored
// Since the logger provides the numeric log level, we need to convert it to a | ||
// string for the log message. | ||
const getLogLevelString = (level: Realm.App.Sync.NumericLogLevel) => { | ||
switch (level) { |
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.
Why not use an object literal? And let it default to DEFALT_LOG_LEVEL
?
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.
I like the split off the various console methods! (Apologies for late review, this went under my radar)
|
||
// Since the logger provides the numeric log level, we need to convert it to a | ||
// string for the log message. | ||
const getLogLevelString = (level: Realm.App.Sync.NumericLogLevel) => { |
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.
NumericLogLevel.All
and NumericLogLevel.Off
as well 👍
I may be closing this, as the effort @papafe is currently doing will probably nullify this, as well as the |
What, How & Why?
The default logger could be a bit smarter. This will print a contextual log message with the level and use either
console.error
,console.warn
andconsole.log
based on the relevant level. This also sets a default log level to WARN.☑️ ToDos
Compatibility
label is updated or copied from previous entryCOMPATIBILITY.md
package.json
s (if updating internal packages)Breaking
label has been applied or is not necessaryIf this PR adds or changes public API's: