-
Notifications
You must be signed in to change notification settings - Fork 462
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
Add logging developer guideline #5175
Conversation
/assign |
b44a7b4
to
b1a300d
Compare
Fixed the unit tests by adapting them to the changes in the last commit. |
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.
Very nice!
b1a300d
to
4e5fa93
Compare
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.
/lgtm
/squash
Thanks for all your feedback! |
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 also like it very much. I also "tested" it by switching to logr.Logger
in #5150, and it "worked" fine (but I still needed some advice from @timebertt, see below). Still, I have a few comments that I consider relatively important.
e7da935
to
1ba9356
Compare
@stoyanr thanks for your feedback as well. I addressed your comments in new commits. PTAL :) |
/retest |
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.
@timebertt Thanks for addressing my suggestions!
/lgtm
* Add logging developer guideline * Follow logging guideline in already refactored controllers * Consistently capitalize error logs * Consistently capitalize info logs * Address review comments * Address more feedback * Clarify the level mapping * Discourage use of kutil.ObjectName * Add some notes about the migration
* Add logging developer guideline * Follow logging guideline in already refactored controllers * Consistently capitalize error logs * Consistently capitalize info logs * Address review comments * Address more feedback * Clarify the level mapping * Discourage use of kutil.ObjectName * Add some notes about the migration
How to categorize this PR?
/area documentation dev-productivity logging
/kind enhancement
What this PR does / why we need it:
In the context of #4251, we are migrating our components from
logrus
tologr
(see #5057 for part 1).As migrating to a new logging library and also a new logging style (structured logging) brings up a lot of questions and confusion, I proactively try to clarify them in a developer guideline around logging in our components.
Also, this guideline will hopefully bring more consistency into logging in our codebase.
This should be consulted by developers adding new logs or refactoring existing code (like me), as well as reviewers.
I hope that it will be useful for them, so that they don't have to read up on so many things and dig through logging code to figure out how to best write a simple log statement in some controller.
Which issue(s) this PR fixes:
Part of #4251
Special notes for your reviewer:
After "formalizing" the guideline, I went over the code touched by #5057 again and applied it to it. That's also why I'm adding this guideline now, so that I have something to follow along the way as well :)
Also, I cleaned up some "obvious" inconsistencies in the codebase with the guideline already (mainly regarding the capitalization part).
I only touched
logr
statements for now, as the rest will be touched later on anyways.Further inconsistencies like e.g.
fmt.Sprintf
usage in log messages can be cleaned up later on in dedicated PRs./squash
Release note:
A developer guideline on logging in Gardener components has been added. Please consult this document as a developer or reviewer to ensure consistency in our logs across the codebase. You can find the document [here](https://github.com/gardener/gardener/blob/master/docs/development/logging.md).