Skip to content

Commit

Permalink
Logging what really caused lookup failure (#450)
Browse files Browse the repository at this point in the history
* Logging what caused lookup failure

* Logging by fields
  • Loading branch information
wuYin committed Jan 25, 2021
1 parent 462394f commit a1dca8c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pulsar/internal/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
13 changes: 6 additions & 7 deletions pulsar/internal/lookup_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package internal

import (
"errors"
"fmt"
"net/url"

"github.com/gogo/protobuf/proto"
Expand Down Expand Up @@ -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())
}
}

Expand Down

0 comments on commit a1dca8c

Please sign in to comment.