From 4e0d69143208d713e88880d5af1c86f4386e425c Mon Sep 17 00:00:00 2001 From: Kent Dong Date: Thu, 30 Apr 2026 18:03:33 +0800 Subject: [PATCH] fix: fix non-json logs with log_as_json enabled (#3779) Signed-off-by: CH3CHO --- cmd/higress/main.go | 2 +- pkg/cert/certmgr.go | 8 +------- registry/consul/watcher.go | 2 +- registry/direct/watcher.go | 3 +-- registry/eureka/client/http_client.go | 2 +- registry/eureka/client/plan.go | 2 +- registry/eureka/watcher.go | 2 +- registry/memory/cache.go | 2 +- registry/nacos/address/address_discovery.go | 2 +- registry/nacos/v2/watcher.go | 2 +- registry/nacos/watcher.go | 2 +- registry/reconcile/reconcile.go | 2 +- registry/watcher.go | 2 +- registry/zookeeper/watcher.go | 4 ++-- 14 files changed, 15 insertions(+), 22 deletions(-) diff --git a/cmd/higress/main.go b/cmd/higress/main.go index 065697e10..18da6c0c8 100644 --- a/cmd/higress/main.go +++ b/cmd/higress/main.go @@ -18,7 +18,7 @@ import ( "fmt" "os" - "istio.io/pkg/log" + "istio.io/istio/pkg/log" "github.com/alibaba/higress/v2/pkg/cmd" ) diff --git a/pkg/cert/certmgr.go b/pkg/cert/certmgr.go index db5a03019..ee41b1281 100644 --- a/pkg/cert/certmgr.go +++ b/pkg/cert/certmgr.go @@ -17,14 +17,12 @@ package cert import ( "context" "fmt" - "os" "reflect" "sync" "github.com/caddyserver/certmagic" "github.com/mholt/acmez" "go.uber.org/zap" - "go.uber.org/zap/zapcore" istiomodel "istio.io/istio/pilot/pkg/model" "k8s.io/client-go/kubernetes" ) @@ -60,11 +58,7 @@ func InitCertMgr(opts *Option, clientSet kubernetes.Interface, config *Config, X var storage certmagic.Storage storage, _ = NewConfigmapStorage(opts.Namespace, clientSet) renewalWindowRatio := float64(config.RenewBeforeDays) / float64(RenewMaxDays) - logger := zap.New(zapcore.NewCore( - zapcore.NewConsoleEncoder(zap.NewProductionEncoderConfig()), - os.Stderr, - zap.DebugLevel, - )) + logger := zap.L() magicConfig := certmagic.Config{ RenewalWindowRatio: renewalWindowRatio, Storage: storage, diff --git a/registry/consul/watcher.go b/registry/consul/watcher.go index ea950c4ed..852681284 100644 --- a/registry/consul/watcher.go +++ b/registry/consul/watcher.go @@ -23,7 +23,7 @@ import ( consulapi "github.com/hashicorp/consul/api" "github.com/hashicorp/consul/api/watch" "istio.io/api/networking/v1alpha3" - "istio.io/pkg/log" + "istio.io/istio/pkg/log" apiv1 "github.com/alibaba/higress/v2/api/networking/v1" "github.com/alibaba/higress/v2/pkg/common" diff --git a/registry/direct/watcher.go b/registry/direct/watcher.go index a928e3fa5..6b3ae4220 100644 --- a/registry/direct/watcher.go +++ b/registry/direct/watcher.go @@ -22,7 +22,7 @@ import ( "sync" "istio.io/api/networking/v1alpha3" - "istio.io/pkg/log" + "istio.io/istio/pkg/log" apiv1 "github.com/alibaba/higress/v2/api/networking/v1" "github.com/alibaba/higress/v2/pkg/common" @@ -268,4 +268,3 @@ func (w *watcher) getSni(se *v1alpha3.ServiceEntry) string { func (w *watcher) GetRegistryType() string { return w.RegistryConfig.Type } - diff --git a/registry/eureka/client/http_client.go b/registry/eureka/client/http_client.go index bfec44cfe..2c678fd0a 100644 --- a/registry/eureka/client/http_client.go +++ b/registry/eureka/client/http_client.go @@ -24,7 +24,7 @@ import ( "github.com/avast/retry-go/v4" "github.com/hudl/fargo" - "istio.io/pkg/log" + "istio.io/istio/pkg/log" ) var httpClient = http.DefaultClient diff --git a/registry/eureka/client/plan.go b/registry/eureka/client/plan.go index 291211e8a..0ca73ad5c 100644 --- a/registry/eureka/client/plan.go +++ b/registry/eureka/client/plan.go @@ -16,7 +16,7 @@ package client import ( "github.com/hudl/fargo" - "istio.io/pkg/log" + "istio.io/istio/pkg/log" ) type Handler func(application *fargo.Application) error diff --git a/registry/eureka/watcher.go b/registry/eureka/watcher.go index 0c3db8553..17cfef5e4 100644 --- a/registry/eureka/watcher.go +++ b/registry/eureka/watcher.go @@ -23,7 +23,7 @@ import ( "github.com/hudl/fargo" "istio.io/api/networking/v1alpha3" - "istio.io/pkg/log" + "istio.io/istio/pkg/log" apiv1 "github.com/alibaba/higress/v2/api/networking/v1" "github.com/alibaba/higress/v2/pkg/common" diff --git a/registry/memory/cache.go b/registry/memory/cache.go index 60cbf2ade..ea103f91f 100644 --- a/registry/memory/cache.go +++ b/registry/memory/cache.go @@ -28,7 +28,7 @@ import ( "istio.io/api/networking/v1alpha3" "istio.io/istio/pkg/config" "istio.io/istio/pkg/config/schema/gvk" - "istio.io/pkg/log" + "istio.io/istio/pkg/log" "github.com/alibaba/higress/v2/pkg/common" higressconfig "github.com/alibaba/higress/v2/pkg/config" diff --git a/registry/nacos/address/address_discovery.go b/registry/nacos/address/address_discovery.go index 69e4edfc9..e8621efcd 100644 --- a/registry/nacos/address/address_discovery.go +++ b/registry/nacos/address/address_discovery.go @@ -25,7 +25,7 @@ import ( "time" "go.uber.org/atomic" - "istio.io/pkg/log" + "istio.io/istio/pkg/log" ) const ( diff --git a/registry/nacos/v2/watcher.go b/registry/nacos/v2/watcher.go index 1d3363408..fd6f52030 100644 --- a/registry/nacos/v2/watcher.go +++ b/registry/nacos/v2/watcher.go @@ -32,7 +32,7 @@ import ( "github.com/nacos-group/nacos-sdk-go/v2/vo" "go.uber.org/atomic" "istio.io/api/networking/v1alpha3" - "istio.io/pkg/log" + "istio.io/istio/pkg/log" apiv1 "github.com/alibaba/higress/v2/api/networking/v1" "github.com/alibaba/higress/v2/pkg/common" diff --git a/registry/nacos/watcher.go b/registry/nacos/watcher.go index de44a149c..bcbef38b7 100644 --- a/registry/nacos/watcher.go +++ b/registry/nacos/watcher.go @@ -27,7 +27,7 @@ import ( "github.com/nacos-group/nacos-sdk-go/model" "github.com/nacos-group/nacos-sdk-go/vo" "istio.io/api/networking/v1alpha3" - "istio.io/pkg/log" + "istio.io/istio/pkg/log" apiv1 "github.com/alibaba/higress/v2/api/networking/v1" "github.com/alibaba/higress/v2/pkg/common" diff --git a/registry/reconcile/reconcile.go b/registry/reconcile/reconcile.go index ce68daa74..1f08f1f31 100644 --- a/registry/reconcile/reconcile.go +++ b/registry/reconcile/reconcile.go @@ -23,7 +23,7 @@ import ( "sync" "time" - "istio.io/pkg/log" + "istio.io/istio/pkg/log" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" apiv1 "github.com/alibaba/higress/v2/api/networking/v1" diff --git a/registry/watcher.go b/registry/watcher.go index 6e0fa13e6..f8d0d05b4 100644 --- a/registry/watcher.go +++ b/registry/watcher.go @@ -21,7 +21,7 @@ import ( apiv1 "github.com/alibaba/higress/v2/api/networking/v1" "istio.io/api/networking/v1alpha3" - "istio.io/pkg/log" + "istio.io/istio/pkg/log" ) const ( diff --git a/registry/zookeeper/watcher.go b/registry/zookeeper/watcher.go index dc81e3bf8..1bda13731 100644 --- a/registry/zookeeper/watcher.go +++ b/registry/zookeeper/watcher.go @@ -30,7 +30,7 @@ import ( "github.com/hashicorp/go-multierror" "go.uber.org/atomic" "istio.io/api/networking/v1alpha3" - "istio.io/pkg/log" + "istio.io/istio/pkg/log" apiv1 "github.com/alibaba/higress/v2/api/networking/v1" "github.com/alibaba/higress/v2/pkg/common" @@ -665,7 +665,7 @@ func (w *watcher) Run() { defer func() { log.Info("[zookeeper] Run is down") if r := recover(); r != nil { - log.Info("Recovered in f", "r is", r) + log.Infof("Recovered in Run: %v", r) } }() ticker := time.NewTicker(30 * time.Second)