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
}
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)

@ -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()

@ -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")
}

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

@ -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 {

Loading…
Cancel
Save