Skip to content
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

chore: add WARN, ERROR and TRACE log levels #232

Merged
merged 11 commits into from
Mar 7, 2023
Merged

Conversation

poppoerika
Copy link
Contributor

@poppoerika poppoerika commented Mar 6, 2023

  • Added WARN, ERROR and TRACE log levels
  • Updated MomentoLoggerFactory's GetLogger to take logLevel to log correctly based on a requested log level
  • Updated MomentoLogger functions to log based on a requested log level
  • Added TRACE logging when detecting an unrecognized response besides Discontinuity, Item, and Heartbeat for topic subscription

Also

  • Rename simple_cache_client.go to cache_client.go.

Closes #157

Comment on lines 16 to 18
if len(args) != 0 {
logWithArgs(l.level, l.loggerName, message, args...)
} else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can save a lot of code by just using one log method and checking len(args) there. There's no need for logWith and logWithout because variadic args are not required (which is how they can have a zero length).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡

Comment on lines 26 to 30
func (l *BuiltinMomentoLogger) Warn(message string, args ...string) {
if l.level == WARN {
momentoLog(l.level, l.loggerName, message, args...)
}
}
Copy link
Contributor

@schwern schwern Mar 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means a warning will not show up if the log level is set to a more detailed log level. For example, if the level is TRACE it won't log a warning.

This is easier if the log levels are defined as numbers in order of severity. Then it's if l.level >= WARN.

@poppoerika poppoerika merged commit 0b8d13e into main Mar 7, 2023
@poppoerika poppoerika deleted the chore/update-logger branch March 7, 2023 00:02
cprice404 pushed a commit that referenced this pull request Mar 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add standard debug/warn/error logging for user
3 participants