Skip to content

Commit

Permalink
set klog logger (#3833)
Browse files Browse the repository at this point in the history
this ensures that the leader election will also use the configured logger
  • Loading branch information
mycrEEpy authored Sep 23, 2024
1 parent 644600a commit dc7e051
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ require (
k8s.io/apimachinery v0.30.0
k8s.io/cli-runtime v0.30.0
k8s.io/client-go v0.30.0
k8s.io/klog/v2 v2.120.1
k8s.io/utils v0.0.0-20240502163921-fe8a2dddb1d0
sigs.k8s.io/controller-runtime v0.18.2
sigs.k8s.io/yaml v1.4.0
Expand Down Expand Up @@ -166,7 +167,6 @@ require (
k8s.io/apiextensions-apiserver v0.30.0 // indirect
k8s.io/apiserver v0.30.0 // indirect
k8s.io/component-base v0.30.0 // indirect
k8s.io/klog/v2 v2.120.1 // indirect
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect
k8s.io/kubectl v0.30.0 // indirect
moul.io/http2curl/v2 v2.3.0 // indirect
Expand Down
5 changes: 4 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"k8s.io/client-go/kubernetes"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
"k8s.io/klog/v2"
elbv2api "sigs.k8s.io/aws-load-balancer-controller/apis/elbv2/v1beta1"
elbv2controller "sigs.k8s.io/aws-load-balancer-controller/controllers/elbv2"
"sigs.k8s.io/aws-load-balancer-controller/controllers/ingress"
Expand Down Expand Up @@ -75,7 +76,9 @@ func main() {
infoLogger.Error(err, "unable to load controller config")
os.Exit(1)
}
ctrl.SetLogger(getLoggerWithLogLevel(controllerCFG.LogLevel))
appLogger := getLoggerWithLogLevel(controllerCFG.LogLevel)
ctrl.SetLogger(appLogger)
klog.SetLoggerWithOptions(appLogger, klog.ContextualLogger(true))

cloud, err := aws.NewCloud(controllerCFG.AWSConfig, metrics.Registry, ctrl.Log)
if err != nil {
Expand Down

0 comments on commit dc7e051

Please sign in to comment.