Skip to content
This repository is currently being migrated. It's locked while the migration is in progress.

Commit

Permalink
Configure zap logger for klog (#102)
Browse files Browse the repository at this point in the history
  • Loading branch information
mhmxs authored Nov 11, 2021
1 parent d1db431 commit d069578
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ require (
k8s.io/api v0.20.2
k8s.io/apimachinery v0.20.2
k8s.io/client-go v0.20.2
k8s.io/klog/v2 v2.4.0
sigs.k8s.io/controller-runtime v0.8.3
)
6 changes: 5 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import (
"k8s.io/apimachinery/pkg/types"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
"k8s.io/klog/v2"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
Expand Down Expand Up @@ -188,7 +189,10 @@ func main() {
encoderOpts := func(o *zap.Options) {
o.EncoderConfigOptions = append(o.EncoderConfigOptions, f)
}
ctrl.SetLogger(zap.New(zap.UseFlagOptions(&loggerOpts), zap.StacktraceLevel(zapcore.PanicLevel), encoderOpts))

zapLogger := zap.New(zap.UseFlagOptions(&loggerOpts), zap.StacktraceLevel(zapcore.PanicLevel), encoderOpts)
ctrl.SetLogger(zapLogger)
klog.SetLogger(zapLogger)

// Setup telemetry.
telemetryShutdown, err := export.InstallJaegerExporter("api-manager")
Expand Down
1 change: 1 addition & 0 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,7 @@ k8s.io/client-go/util/workqueue
k8s.io/component-base/config
k8s.io/component-base/config/v1alpha1
# k8s.io/klog/v2 v2.4.0
## explicit
k8s.io/klog/v2
# k8s.io/kube-openapi v0.0.0-20201113171705-d219536bb9fd
k8s.io/kube-openapi/pkg/util/proto
Expand Down

0 comments on commit d069578

Please sign in to comment.