From d4c0c576819e29f5103a8b1e3c44d88dcecc7e86 Mon Sep 17 00:00:00 2001 From: Cluas Date: Tue, 29 Mar 2022 16:39:31 +0800 Subject: [PATCH] feat(log): log load config only when Debug level (#1899) --- config/config.go | 2 +- contrib/registry/discovery/discovery.go | 8 ++++---- contrib/registry/discovery/impl_discover.go | 4 ++-- contrib/registry/polaris/registry.go | 1 - log/log.go | 2 +- 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/config/config.go b/config/config.go index 783cc25c1..fa8aa430b 100644 --- a/config/config.go +++ b/config/config.go @@ -104,7 +104,7 @@ func (c *config) Load() error { return err } for _, v := range kvs { - c.log.Infof("config loaded: %s format: %s", v.Key, v.Format) + c.log.Debugf("config loaded: %s format: %s", v.Key, v.Format) } if err = c.reader.Merge(kvs...); err != nil { c.log.Errorf("failed to merge config source: %v", err) diff --git a/contrib/registry/discovery/discovery.go b/contrib/registry/discovery/discovery.go index d122989b4..9c85c0ab2 100644 --- a/contrib/registry/discovery/discovery.go +++ b/contrib/registry/discovery/discovery.go @@ -79,7 +79,7 @@ func New(c *Config, logger log.Logger) *Discovery { if !ok { panic("Discovery watch self failed") } - discoveryIns, ok := r.Fetch(context.Background()) + discoveryIns, ok := r.fetch(context.Background()) if ok { d.newSelf(discoveryIns.Instances) } @@ -105,7 +105,7 @@ func (d *Discovery) selfProc(resolver *Resolve, event <-chan struct{}) { if !ok { return } - zones, ok := resolver.Fetch(context.Background()) + zones, ok := resolver.fetch(context.Background()) if ok { d.newSelf(zones.Instances) } @@ -444,8 +444,8 @@ func (r *Resolve) Watch() <-chan struct{} { return r.event } -// Fetch resolver instance. -func (r *Resolve) Fetch(ctx context.Context) (ins *disInstancesInfo, ok bool) { +// fetch resolver instance. +func (r *Resolve) fetch(ctx context.Context) (ins *disInstancesInfo, ok bool) { r.d.mutex.RLock() app, ok := r.d.apps[r.id] r.d.mutex.RUnlock() diff --git a/contrib/registry/discovery/impl_discover.go b/contrib/registry/discovery/impl_discover.go index b8dd470ca..fb1b01d15 100644 --- a/contrib/registry/discovery/impl_discover.go +++ b/contrib/registry/discovery/impl_discover.go @@ -29,7 +29,7 @@ func filterInstancesByZone(ins *disInstancesInfo, zone string) []*registry.Servi func (d *Discovery) GetService(ctx context.Context, serviceName string) ([]*registry.ServiceInstance, error) { r := d.resolveBuild(serviceName) - ins, ok := r.Fetch(ctx) + ins, ok := r.fetch(ctx) if !ok { return nil, errors.New("Discovery.GetService fetch failed") } @@ -70,7 +70,7 @@ func (w *watcher) Next() ([]*registry.ServiceInstance, error) { ctx, cancel := context.WithTimeout(context.TODO(), 15*time.Second) defer cancel() - ins, ok := w.Resolve.Fetch(ctx) + ins, ok := w.Resolve.fetch(ctx) if !ok { return nil, errors.New("Discovery.GetService fetch failed") } diff --git a/contrib/registry/polaris/registry.go b/contrib/registry/polaris/registry.go index 2b1c523c5..d9b87150c 100644 --- a/contrib/registry/polaris/registry.go +++ b/contrib/registry/polaris/registry.go @@ -27,7 +27,6 @@ var ( const _instanceIDSeparator = "-" type options struct { - // required, namespace in polaris Namespace string diff --git a/log/log.go b/log/log.go index d5d2a89b6..1b612f8b8 100644 --- a/log/log.go +++ b/log/log.go @@ -6,7 +6,7 @@ import ( ) // DefaultLogger is default logger. -var DefaultLogger Logger = NewStdLogger(log.Writer()) +var DefaultLogger = NewStdLogger(log.Writer()) // Logger is a logger interface. type Logger interface {