-
Notifications
You must be signed in to change notification settings - Fork 515
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
Drop klog and migrate to logging package #1178
Conversation
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.
Looks great. I'll want to do another pass, but as a quick skim, just caught one apparent typo.
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.
Looks great, nice touches adjusting a couple of the overly-verbose log levels!
log.Info().Msgf(fmt.Sprintf("[Profiler] %s", format), a...) | ||
} |
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.
Profilef
seems like a good candidate for a somewhat structured log, maybe:
// "type" is such an overloaded word, I'm not sure
// what the best practice is for structured log keys
log.Info().Str("type", "profile").Msgf(...)
What do you think?
I totally understand if you want to leave this kind of update for another time.
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.
Yeah, how and what to add is a good question. We could potentially turn the profile logger into a sub logger i.e. https://github.com/rs/zerolog#sub-loggers-let-you-chain-loggers-with-additional-context
I don't have enough context yet to say where to go with the profile logger, perhaps it should end up behind a flag so it's not always printing logs since profiling is usually resource intensive and not always needed.
This is beautiful - Viper looks helpful, maybe we can leverage it more in some other areas where we have config chaos. |
What does this PR change?
Removed klog from all of our logging - it is still used in packages we depend on (k8s-client)
Moved all klog calls to our logging package which now uses zerolog under the hood
Defaulted to using a pretty style printing to keep the output similar to existing logging. This can be changed to json with a flag/envvar which should technically be faster. We don't fully take advantage of the structured part yet but it would still be better than nothing if a user wants to use it.
New logging format:
Old logging format:
Note that the file and line number has been dropped. If this is deemed required it can be added back or have a flag to disable/enable it
Does this PR relate to any other PRs?
Not yet
How will this PR impact users?
The logging output will look different but similar. See above about JSON stuff.
Does this PR address any GitHub or Zendesk issues?
#1170
How was this PR tested?
Swapped out logging and run kubecost
Does this PR require changes to documentation?
Have you labeled this PR and its corresponding Issue as "next release" if it should be part of the next Kubecost release? If not, why not?