-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
♻️ Another pass at reducing complexity around Log
#35461
Conversation
@@ -211,7 +180,7 @@ export class Log { | |||
} | |||
|
|||
// LocalDev by default allows INFO level, unless overriden by `#log`. | |||
if (getMode().localDev && !getMode().log) { | |||
if (getMode().localDev) { |
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.
getMode().log == 0
above implies !getMode().log
already
@@ -224,46 +193,40 @@ export class Log { | |||
*/ | |||
defaultLevelWithFunc_() { | |||
// Delegate to the specific resolver. | |||
return this.levelFunc_(parseInt(getMode().log, 10), getMode().development); | |||
return this.levelFunc_(getMode().log, getMode().development); |
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.
moved parsing into mode
*/ | ||
isEnabled() { | ||
return this.getLevel_() != LogLevel.OFF; | ||
return true; |
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.
isEnabled
wasn't used anywhere.
|
||
return this.messages_?.[id] | ||
? [this.messages_[id]].concat(parts) | ||
: [`More info at ${externalMessageUrl(id, parts)}`]; |
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.
This code is mostly untouched, but I moved all the assert
helpers to the end of the class definition so the rest of the log/error methods were together.
Log
Log
Hey @jridgewell! These files were changed:
|
@jridgewell bumping this |
@rcebulko you are my hero |
} | ||
|
||
const cs = this.win.console; | ||
const fn = |
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.
clever, but IMO harder to read. not b/c the pattern is inherently worse, its just super uncommon
|
||
return this.messages_?.[id] | ||
? [this.messages_[id]].concat(parts) | ||
: [`More info at ${externalMessageUrl(id, parts)}`]; |
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.
FMI: do you know if this code is actually active? I didn't realize we even had started on this feature
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 has never been used/shipped, but was working (though untested) at one point. The transforms likely need updating since much of assertion code has been moved.
setReportError
toerror-reporting
#core/error/message-helpers
Log
methods/constructor helpers