-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
✨ Use klog
as the controller-runtime default logger
#2021
Conversation
Welcome @astraw99! |
Hi @astraw99. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: astraw99 The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/ok-to-test I prefer klog, but not sure if it is ok for compatibility. And this PR needs to be marked as breaking since we change the default logger. |
1f9ff38
to
7a8c3c6
Compare
7a8c3c6
to
e5c184c
Compare
@@ -81,7 +83,8 @@ var ( | |||
// set to a NullLogSink. | |||
var ( | |||
dlog = NewDelegatingLogSink(NullLogSink{}) | |||
Log = logr.New(dlog) | |||
// Log uses `klog` as the controller-runtime default logger. | |||
Log = klog.NewKlogr() |
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 is a breaking change. Controller-Runtime doesn't set any logger by default and allows people to use whatever logger they like for as long as it implements the interface. We want to keep offering that.
Please just set your desired logger at the start of your program.
/hold
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.
Got it, raised a new PR kubernetes-sigs/kubebuilder#3033 to set the default logger.
PTAL thanks.
C-R intentionally uses an interface that you can put whatever logger implementation you like most into, so I don't think we want to merge this. |
Fixes #2024
To make the log output consistent with K8s core components (kube-apiserver, kube-controller-manager, etc), and
more human readable.
Test results:
Before this PR, the kubebuilder generated controller-manager log is:
After this PR, the kubebuilder generated controller-manager log is: