Skip to content

Commit

Permalink
Fix logging of keys.
Browse files Browse the repository at this point in the history
Currently keys that get logged are casted from []byte. Which means that log output looks like this.
```
{"event":"getClosestPeersBegin","key":"\u0012 \ufffdᱡ\ufffd`\ufffdF]\ufffd\ufffdᠸCƶ\u0006E\ufffdrb\ufffd\ufffdO\ufffd\ufffdu\ufffd\ufffdj\u000b","system":"dht","time":"2017-07-27T11:12:08.51775836Z"}
```
after fix like this:
```
{"event":"getClosestPeersBegin","key":"QmQyyaB8znrakGydP3ynRsXre96Uw9wc6w6zuP61bbZuNj","system":"dht","time":"2017-07-27T11:16:30.693008112Z"}
```
  • Loading branch information
tvi authored Jul 27, 2017
1 parent 0b7a077 commit ff9720c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lookup.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package dht
import (
"context"

cid "github.com/ipfs/go-cid"
logging "github.com/ipfs/go-log"
kb "github.com/libp2p/go-libp2p-kbucket"
peer "github.com/libp2p/go-libp2p-peer"
Expand All @@ -29,6 +30,9 @@ func toPeerInfos(ps []peer.ID) []*pstore.PeerInfo {
}

func loggableKey(k string) logging.LoggableMap {
if cid, err := cid.Cast([]byte(k)); err == nil {
k = cid.String()
}
return logging.LoggableMap{
"key": k,
}
Expand Down

0 comments on commit ff9720c

Please sign in to comment.