Skip to content

Commit

Permalink
feat: print logs of registered providers and consumers (#2320)
Browse files Browse the repository at this point in the history
fixes #2319
  • Loading branch information
ev1lQuark authored Jun 3, 2023
1 parent 12f5211 commit b998087
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
16 changes: 15 additions & 1 deletion config/consumer_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package config

import (
"fmt"
"strings"
"time"
)

Expand Down Expand Up @@ -65,12 +66,25 @@ func (cc *ConsumerConfig) Init(rc *RootConfig) error {
if cc == nil {
return nil
}

buildDebugMsg := func() string {
if len(cc.References) == 0 {
return "empty"
}
consumerNames := make([]string, 0, len(cc.References))
for k := range cc.References {
consumerNames = append(consumerNames, k)
}
return strings.Join(consumerNames, ", ")
}
logger.Debugf("Registered consumer clients are %v", buildDebugMsg())

cc.RegistryIDs = translateIds(cc.RegistryIDs)
if len(cc.RegistryIDs) <= 0 {
cc.RegistryIDs = rc.getRegistryIds()
}
if cc.TracingKey == "" && len(rc.Tracing) > 0 {
for k, _ := range rc.Tracing {
for k := range rc.Tracing {
cc.TracingKey = k
break
}
Expand Down
15 changes: 14 additions & 1 deletion config/provider_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package config

import (
"fmt"
"strings"
)

import (
Expand Down Expand Up @@ -75,14 +76,26 @@ func (c *ProviderConfig) Init(rc *RootConfig) error {
if c == nil {
return nil
}
buildDebugMsg := func() string {
if len(c.Services) == 0 {
return "empty"
}
providerNames := make([]string, 0, len(c.Services))
for k := range c.Services {
providerNames = append(providerNames, k)
}
return strings.Join(providerNames, ", ")
}
logger.Debugf("Registered provider services are %v", buildDebugMsg())

c.RegistryIDs = translateIds(c.RegistryIDs)
if len(c.RegistryIDs) <= 0 {
c.RegistryIDs = rc.getRegistryIds()
}
c.ProtocolIDs = translateIds(c.ProtocolIDs)

if c.TracingKey == "" && len(rc.Tracing) > 0 {
for k, _ := range rc.Tracing {
for k := range rc.Tracing {
c.TracingKey = k
break
}
Expand Down

0 comments on commit b998087

Please sign in to comment.