feat(log): log load config only when Debug level (#1899)

pull/1902/head
Cluas 3 years ago committed by GitHub
parent 69df1ab9a6
commit d4c0c57681
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      config/config.go
  2. 8
      contrib/registry/discovery/discovery.go
  3. 4
      contrib/registry/discovery/impl_discover.go
  4. 1
      contrib/registry/polaris/registry.go
  5. 2
      log/log.go

@ -104,7 +104,7 @@ func (c *config) Load() error {
return err return err
} }
for _, v := range kvs { 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 { if err = c.reader.Merge(kvs...); err != nil {
c.log.Errorf("failed to merge config source: %v", err) c.log.Errorf("failed to merge config source: %v", err)

@ -79,7 +79,7 @@ func New(c *Config, logger log.Logger) *Discovery {
if !ok { if !ok {
panic("Discovery watch self failed") panic("Discovery watch self failed")
} }
discoveryIns, ok := r.Fetch(context.Background()) discoveryIns, ok := r.fetch(context.Background())
if ok { if ok {
d.newSelf(discoveryIns.Instances) d.newSelf(discoveryIns.Instances)
} }
@ -105,7 +105,7 @@ func (d *Discovery) selfProc(resolver *Resolve, event <-chan struct{}) {
if !ok { if !ok {
return return
} }
zones, ok := resolver.Fetch(context.Background()) zones, ok := resolver.fetch(context.Background())
if ok { if ok {
d.newSelf(zones.Instances) d.newSelf(zones.Instances)
} }
@ -444,8 +444,8 @@ func (r *Resolve) Watch() <-chan struct{} {
return r.event return r.event
} }
// Fetch resolver instance. // fetch resolver instance.
func (r *Resolve) Fetch(ctx context.Context) (ins *disInstancesInfo, ok bool) { func (r *Resolve) fetch(ctx context.Context) (ins *disInstancesInfo, ok bool) {
r.d.mutex.RLock() r.d.mutex.RLock()
app, ok := r.d.apps[r.id] app, ok := r.d.apps[r.id]
r.d.mutex.RUnlock() r.d.mutex.RUnlock()

@ -29,7 +29,7 @@ func filterInstancesByZone(ins *disInstancesInfo, zone string) []*registry.Servi
func (d *Discovery) GetService(ctx context.Context, serviceName string) ([]*registry.ServiceInstance, error) { func (d *Discovery) GetService(ctx context.Context, serviceName string) ([]*registry.ServiceInstance, error) {
r := d.resolveBuild(serviceName) r := d.resolveBuild(serviceName)
ins, ok := r.Fetch(ctx) ins, ok := r.fetch(ctx)
if !ok { if !ok {
return nil, errors.New("Discovery.GetService fetch failed") 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) ctx, cancel := context.WithTimeout(context.TODO(), 15*time.Second)
defer cancel() defer cancel()
ins, ok := w.Resolve.Fetch(ctx) ins, ok := w.Resolve.fetch(ctx)
if !ok { if !ok {
return nil, errors.New("Discovery.GetService fetch failed") return nil, errors.New("Discovery.GetService fetch failed")
} }

@ -27,7 +27,6 @@ var (
const _instanceIDSeparator = "-" const _instanceIDSeparator = "-"
type options struct { type options struct {
// required, namespace in polaris // required, namespace in polaris
Namespace string Namespace string

@ -6,7 +6,7 @@ import (
) )
// DefaultLogger is default logger. // DefaultLogger is default logger.
var DefaultLogger Logger = NewStdLogger(log.Writer()) var DefaultLogger = NewStdLogger(log.Writer())
// Logger is a logger interface. // Logger is a logger interface.
type Logger interface { type Logger interface {

Loading…
Cancel
Save