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

mmerli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar-client-go.git


The following commit(s) were added to refs/heads/master by this push:
     new a1dca8c  Logging what really caused lookup failure (#450)
a1dca8c is described below

commit a1dca8c4e31eb6522bc40e2de4882be74266a657
Author: wuYin <[email protected]>
AuthorDate: Tue Jan 26 01:45:39 2021 +0800

    Logging what really caused lookup failure (#450)
    
    * Logging what caused lookup failure
    
    * Logging by fields
---
 pulsar/internal/connection.go     |  2 +-
 pulsar/internal/lookup_service.go | 13 ++++++-------
 2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/pulsar/internal/connection.go b/pulsar/internal/connection.go
index 7010b13..c5572a8 100644
--- a/pulsar/internal/connection.go
+++ b/pulsar/internal/connection.go
@@ -317,7 +317,7 @@ func (c *connection) waitUntilReady() error {
        defer c.Unlock()
 
        for c.state != connectionReady {
-               c.log.Debug("Wait until connection is ready. State: ", c.state)
+               c.log.Debugf("Wait until connection is ready. State: %s", 
connectionState(c.state))
                if c.state == connectionClosed {
                        return errors.New("connection error")
                }
diff --git a/pulsar/internal/lookup_service.go 
b/pulsar/internal/lookup_service.go
index 7fa76a8..400063d 100644
--- a/pulsar/internal/lookup_service.go
+++ b/pulsar/internal/lookup_service.go
@@ -19,7 +19,6 @@ package internal
 
 import (
        "errors"
-       "fmt"
        "net/url"
 
        "github.com/gogo/protobuf/proto"
@@ -140,12 +139,12 @@ func (ls *lookupService) Lookup(topic string) 
(*LookupResult, error) {
                        }, nil
 
                case pb.CommandLookupTopicResponse_Failed:
-                       errorMsg := ""
-                       if lr.Error != nil {
-                               errorMsg = lr.Error.String()
-                       }
-                       ls.log.Warnf("Failed to lookup topic: %s, error msg: 
%s", topic, errorMsg)
-                       return nil, fmt.Errorf("failed to lookup topic: %s", 
errorMsg)
+                       ls.log.WithFields(log.Fields{
+                               "topic":   topic,
+                               "error":   lr.GetError(),
+                               "message": lr.GetMessage(),
+                       }).Warn("Failed to lookup topic")
+                       return nil, errors.New(lr.GetError().String())
                }
        }
 

Reply via email to