From 2ffaf5f4c1658e17c6df6d6553caba71fbb49839 Mon Sep 17 00:00:00 2001 From: Tao Zou Date: Thu, 18 Jan 2024 11:45:38 +0800 Subject: [PATCH] Update log variant Update log to 'log = logger.Log' --- pkg/metrics/metrics.go | 4 ++-- pkg/nsx/auth/jwt/JWTtokenprovider.go | 5 ++--- pkg/nsx/cluster.go | 4 ++-- pkg/nsx/ratelimiter/ratelimiter.go | 5 +++-- pkg/nsx/util/utils.go | 5 +++-- pkg/util/utils.go | 4 ++-- 6 files changed, 14 insertions(+), 13 deletions(-) diff --git a/pkg/metrics/metrics.go b/pkg/metrics/metrics.go index 5ba9ac84a..748a08fae 100644 --- a/pkg/metrics/metrics.go +++ b/pkg/metrics/metrics.go @@ -4,10 +4,10 @@ import ( "sync" "github.com/prometheus/client_golang/prometheus" - logf "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/metrics" "github.com/vmware-tanzu/nsx-operator/pkg/config" + "github.com/vmware-tanzu/nsx-operator/pkg/logger" ) const ( @@ -24,7 +24,7 @@ const ( ScrapeTimeout = 30 ) -var log = logf.Log.WithName("metrics") +var log = logger.Log var ( NSXOperatorHealthStats = prometheus.NewGauge( diff --git a/pkg/nsx/auth/jwt/JWTtokenprovider.go b/pkg/nsx/auth/jwt/JWTtokenprovider.go index ab4ea4d4b..fba613d4b 100644 --- a/pkg/nsx/auth/jwt/JWTtokenprovider.go +++ b/pkg/nsx/auth/jwt/JWTtokenprovider.go @@ -6,8 +6,7 @@ package jwt import ( "time" - logf "sigs.k8s.io/controller-runtime/pkg/log" - + "github.com/vmware-tanzu/nsx-operator/pkg/logger" "github.com/vmware-tanzu/nsx-operator/pkg/nsx/auth" ) @@ -18,7 +17,7 @@ const ( ) var ( - log = logf.Log.WithName("nsx").WithName("jwt") + log = logger.Log ) type JWTTokenProvider struct { diff --git a/pkg/nsx/cluster.go b/pkg/nsx/cluster.go index ebdcc665e..6b2ba6d42 100644 --- a/pkg/nsx/cluster.go +++ b/pkg/nsx/cluster.go @@ -19,8 +19,8 @@ import ( "time" policyclient "github.com/vmware/vsphere-automation-sdk-go/runtime/protocol/client" - logf "sigs.k8s.io/controller-runtime/pkg/log" + "github.com/vmware-tanzu/nsx-operator/pkg/logger" "github.com/vmware-tanzu/nsx-operator/pkg/nsx/auth" "github.com/vmware-tanzu/nsx-operator/pkg/nsx/ratelimiter" "github.com/vmware-tanzu/nsx-operator/pkg/nsx/util" @@ -54,7 +54,7 @@ type NsxVersion struct { var ( jarCache = NewJar() nsxVersion = &NsxVersion{} - log = logf.Log.WithName("nsx").WithName("cluster") + log = logger.Log ) // NewCluster creates a cluster based on nsx Config. diff --git a/pkg/nsx/ratelimiter/ratelimiter.go b/pkg/nsx/ratelimiter/ratelimiter.go index d1082561b..e70c5edc2 100644 --- a/pkg/nsx/ratelimiter/ratelimiter.go +++ b/pkg/nsx/ratelimiter/ratelimiter.go @@ -9,13 +9,14 @@ import ( "time" "golang.org/x/time/rate" - logf "sigs.k8s.io/controller-runtime/pkg/log" + + "github.com/vmware-tanzu/nsx-operator/pkg/logger" ) // APIReduceRateCodes is http status code set which will trigger rate limiter adjust. var ( APIReduceRateCodes = [2]int{429, 503} - log = logf.Log.WithName("nsx").WithName("ratelimiter") + log = logger.Log ) const ( diff --git a/pkg/nsx/util/utils.go b/pkg/nsx/util/utils.go index 9d138ccc5..c2d976d5c 100644 --- a/pkg/nsx/util/utils.go +++ b/pkg/nsx/util/utils.go @@ -24,10 +24,11 @@ import ( "github.com/vmware/vsphere-automation-sdk-go/runtime/bindings" "github.com/vmware/vsphere-automation-sdk-go/runtime/data" "github.com/vmware/vsphere-automation-sdk-go/services/nsxt/model" - logf "sigs.k8s.io/controller-runtime/pkg/log" + + "github.com/vmware-tanzu/nsx-operator/pkg/logger" ) -var log = logf.Log.WithName("nsx").WithName("utils") +var log = logger.Log // ErrorDetail is error detail which info extracted from http.Response.Body. type ErrorDetail struct { diff --git a/pkg/util/utils.go b/pkg/util/utils.go index d8708a1da..830cffcd1 100644 --- a/pkg/util/utils.go +++ b/pkg/util/utils.go @@ -19,10 +19,10 @@ import ( "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/sets" "sigs.k8s.io/controller-runtime/pkg/client" - logf "sigs.k8s.io/controller-runtime/pkg/log" "github.com/vmware-tanzu/nsx-operator/pkg/apis/v1alpha1" "github.com/vmware-tanzu/nsx-operator/pkg/apis/v1alpha2" + "github.com/vmware-tanzu/nsx-operator/pkg/logger" "github.com/vmware-tanzu/nsx-operator/pkg/nsx/services/common" ) @@ -54,7 +54,7 @@ func init() { } } -var log = logf.Log.WithName("pkg").WithName("utils") +var log = logger.Log func NormalizeLabels(matchLabels *map[string]string) *map[string]string { newLabels := make(map[string]string)