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

configure klog with zap logger #385

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ require (
k8s.io/apimachinery v0.26.3
k8s.io/client-go v0.26.3
k8s.io/component-base v0.26.2
k8s.io/klog/v2 v2.90.1
k8s.io/utils v0.0.0-20230220204549-a5ecb0141aa5
sigs.k8s.io/controller-runtime v0.14.6
sigs.k8s.io/yaml v1.3.0
Expand Down Expand Up @@ -114,7 +115,6 @@ require (
k8s.io/apiextensions-apiserver v0.26.1 // indirect
k8s.io/apiserver v0.26.2 // indirect
k8s.io/klog v1.0.0 // indirect
k8s.io/klog/v2 v2.90.1 // indirect
k8s.io/kms v0.26.2 // indirect
k8s.io/kube-openapi v0.0.0-20230303024457-afdc3dddf62d // indirect
k8s.io/metrics v0.26.2 // indirect
Expand Down
7 changes: 4 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import (
_ "k8s.io/client-go/plugin/pkg/client/auth"
"k8s.io/client-go/rest"
configv1alpha1 "k8s.io/component-base/config/v1alpha1"
"k8s.io/klog/v2"
"k8s.io/utils/pointer"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/healthz"
Expand Down Expand Up @@ -83,9 +84,9 @@ func main() {
TimeEncoder: zapcore.TimeEncoderOfLayout(time.RFC3339),
}
zapOptions.BindFlags(flag.CommandLine)

ctrl.SetLogger(zap.New(zap.UseFlagOptions(&zapOptions)))

zapLog := zap.New(zap.UseFlagOptions(&zapOptions))
ctrl.SetLogger(zapLog)
klog.SetLogger(zapLog)
ctx := ctrl.SetupSignalHandler()

cfg := &config.CodeFlareOperatorConfiguration{
Expand Down
Loading