This is an automated email from the ASF dual-hosted git repository.

liujun pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/dubbo-go.git


The following commit(s) were added to refs/heads/main by this push:
     new b9980875b feat: print logs of registered providers and consumers 
(#2320)
b9980875b is described below

commit b9980875b2ab622914d3ec090019a3ed576981ba
Author: Wang Guan <[email protected]>
AuthorDate: Sat Jun 3 16:20:24 2023 +0800

    feat: print logs of registered providers and consumers (#2320)
    
    fixes #2319
---
 config/consumer_config.go | 16 +++++++++++++++-
 config/provider_config.go | 15 ++++++++++++++-
 2 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/config/consumer_config.go b/config/consumer_config.go
index dd39b46b0..c49811f6a 100644
--- a/config/consumer_config.go
+++ b/config/consumer_config.go
@@ -19,6 +19,7 @@ package config
 
 import (
        "fmt"
+       "strings"
        "time"
 )
 
@@ -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
                }
diff --git a/config/provider_config.go b/config/provider_config.go
index 926fbf62e..364319192 100644
--- a/config/provider_config.go
+++ b/config/provider_config.go
@@ -19,6 +19,7 @@ package config
 
 import (
        "fmt"
+       "strings"
 )
 
 import (
@@ -75,6 +76,18 @@ 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()
@@ -82,7 +95,7 @@ func (c *ProviderConfig) Init(rc *RootConfig) error {
        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
                }

Reply via email to