Skip to content

Commit 604978d

Browse files
committed
fix: set a default controller runtime log
See #185 Signed-off-by: Andrey Smirnov <[email protected]>
1 parent 3719683 commit 604978d

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

main.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
cgrecord "k8s.io/client-go/tools/record"
1818
"k8s.io/component-base/logs"
1919
logsv1 "k8s.io/component-base/logs/api/v1"
20+
"k8s.io/klog/v2"
2021
capiv1 "sigs.k8s.io/cluster-api/api/v1beta1"
2122
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
2223
"sigs.k8s.io/cluster-api/feature"
@@ -80,6 +81,9 @@ func main() {
8081
os.Exit(1)
8182
}
8283

84+
// klog.Background will automatically use the right logger.
85+
ctrl.SetLogger(klog.Background())
86+
8387
// Machine and cluster operations can create enough events to trigger the event recorder spam filter
8488
// Setting the burst size higher ensures all events will be recorded and submitted to the API
8589
broadcaster := cgrecord.NewBroadcasterWithCorrelatorOptions(cgrecord.CorrelatorOptions{

0 commit comments

Comments
 (0)