From 4994c9fbc160b3b07db718bbadf92e4c206991c9 Mon Sep 17 00:00:00 2001 From: Hidde Beydals Date: Wed, 8 Mar 2023 11:04:27 +0100 Subject: [PATCH] Use `logger.SetLogger` to also configure `klog` This uses the newly introduced helper from runtime, which also configures the logger for `klog`. Resulting in all logs now being properly formatted, even when logged by internal Kubernetes elements like the leader election or a dynamic client. The update from `fluxcd/pkg/runtime` from `v0.29.0` to `v0.31.0` in addition includes a change which configures the event recoder to only log on level `trace` (as opposed to `debug`). Signed-off-by: Hidde Beydals --- go.mod | 2 +- go.sum | 6 +++--- main.go | 3 +-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index e6c795da..7d978039 100644 --- a/go.mod +++ b/go.mod @@ -18,7 +18,7 @@ require ( github.com/fluxcd/pkg/git v0.11.0 github.com/fluxcd/pkg/git/gogit v0.8.1 github.com/fluxcd/pkg/gittestserver v0.8.2 - github.com/fluxcd/pkg/runtime v0.29.0 + github.com/fluxcd/pkg/runtime v0.31.0 github.com/fluxcd/pkg/ssh v0.7.3 github.com/fluxcd/source-controller/api v0.35.2 github.com/go-git/go-billy/v5 v5.4.1 diff --git a/go.sum b/go.sum index b9ba051b..9eb50357 100644 --- a/go.sum +++ b/go.sum @@ -139,8 +139,8 @@ github.com/fluxcd/pkg/git/gogit v0.8.1 h1:Q3EV2WBX6HiXSmsHyrwFzwl82gO4ZtFwb675iQ github.com/fluxcd/pkg/git/gogit v0.8.1/go.mod h1:5M27gCl0gyo6l+ht9HwZSzimPY3LahKVIJ7/1vCCctg= github.com/fluxcd/pkg/gittestserver v0.8.2 h1:LzrhnNouKYgZAI2JuuwPcl5ve/TRPo/d7APKIX0LDiI= github.com/fluxcd/pkg/gittestserver v0.8.2/go.mod h1:YhSpqz46mAebmHfP+6QREcNEnmwPLSuklyjsI4h+AR4= -github.com/fluxcd/pkg/runtime v0.29.0 h1:/BDitj/y5shWqczECCiZFsEm9FH7do4VBgMHBiRiol0= -github.com/fluxcd/pkg/runtime v0.29.0/go.mod h1:NrBONYHO5Piuzm6Y7QTS3cJRlgkgsDPn2EKB6gJ4BQw= +github.com/fluxcd/pkg/runtime v0.31.0 h1:addyXaANHl/A68bEjCbiR4HzcFKgfXv1eaG7B7ZHxOo= +github.com/fluxcd/pkg/runtime v0.31.0/go.mod h1:toGOOubMo4ZC1aWhB8C3drdTglr1/A1dETeNwjiIv0g= github.com/fluxcd/pkg/ssh v0.7.3 h1:Dhs+nXdp806lBriUJtPyRi0SVIVWbJafJGD/qQ71GiY= github.com/fluxcd/pkg/ssh v0.7.3/go.mod h1:/z5ZNgQz+h9s/2nNFKAcZDHtZRMA1nj5YcriGDUOoLY= github.com/fluxcd/pkg/version v0.2.1 h1:RRH7+6qiWHdTvRNwpoBmilnubJ2C4FZYGgy5wTDVKVc= @@ -451,8 +451,8 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= github.com/xanzy/ssh-agent v0.3.2/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw= github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw= diff --git a/main.go b/main.go index 25bad806..9d0f2c32 100644 --- a/main.go +++ b/main.go @@ -104,8 +104,7 @@ func main() { flag.Parse() - log := logger.NewLogger(logOptions) - ctrl.SetLogger(log) + logger.SetLogger(logger.NewLogger(logOptions)) err := featureGates.WithLogger(setupLog). SupportedFeatures(features.FeatureGates())