-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
✨ Allow fine-grained configuration of log/zap #560
✨ Allow fine-grained configuration of log/zap #560
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.
Should we have options for the comment settings?
pkg/log/zap/zap.go
Outdated
@@ -29,6 +29,11 @@ import ( | |||
"go.uber.org/zap/zapcore" | |||
) | |||
|
|||
// New returns a brand new Logger configured with Opts |
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.
please note that this (and NewRaw
) use KubeAwareEncoder
also need a comment explaining why we have |
What do you mean by "comment settings"?
The reason I left those is just compatibility, other than that I do not see a good reason for them to exist. Do you know one? Else I would just add that as a comment. |
lol, sorry, "common settings" :-P. Compatibility is the big reason for the others existing. You could also just add // <comment>
//
// Deprecated: Use New(Development) instead or similar |
f888841
to
e825f3a
Compare
@DirectXMan12 I've updated and expanded the godocs and also added the possibility to configure the log level for stracktraces. The only common thing left now that can not be configured is enablement of the |
Seems reasonable to just always enable it |
I think this is good to go, ptal |
// | ||
// Deprecated, use New() and the functional opts pattern instead: | ||
// | ||
// New(func(o *Options){ |
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.
we'll want to follow up (can do it in a follow-up PR) with some predefined options for this, instead of making people write this themselves.
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: alvaroaleman, DirectXMan12 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
📖 add kubebuilder workshop in the book
This PR changes the logger in
pkg/log/zap
to additionally allow configuring the Encoder and the LogLevel. This is done using the functional style opts pattern.Backwards-compatibility is kept by keeping the existing public interface and extending it with a
New
to get alogr.Logger
and aNewRaw
to get a*zap.Logger
.Fixes #442
Closes #467
/assign @DirectXMan12