Logging fixes

This commit is contained in:
Matt Joiner 2020-04-18 17:45:01 +10:00
parent 013fa1df5a
commit 4a2802a702
2 changed files with 4 additions and 3 deletions

View File

@ -1124,9 +1124,10 @@ func (c *PeerConn) onReadExtendedMsg(id pp.ExtensionNumber, payload []byte) (err
case pp.HandshakeExtendedID: case pp.HandshakeExtendedID:
var d pp.ExtendedHandshakeMessage var d pp.ExtendedHandshakeMessage
if err := bencode.Unmarshal(payload, &d); err != nil { if err := bencode.Unmarshal(payload, &d); err != nil {
c.t.logger.Printf("error parsing extended handshake message %q: %s", payload, err) c.logger.Printf("error parsing extended handshake message %q: %s", payload, err)
return errors.Wrap(err, "unmarshalling extended handshake payload") return errors.Wrap(err, "unmarshalling extended handshake payload")
} }
//c.logger.WithDefaultLevel(log.Debug).Printf("received extended handshake message:\n%s", spew.Sdump(d))
if d.Reqq != 0 { if d.Reqq != 0 {
c.PeerMaxRequests = d.Reqq c.PeerMaxRequests = d.Reqq
} }

View File

@ -270,7 +270,7 @@ func (t *Torrent) addPeer(p Peer) (added bool) {
if replaced, ok := t.peers.AddReturningReplacedPeer(p); ok { if replaced, ok := t.peers.AddReturningReplacedPeer(p); ok {
torrent.Add("peers replaced", 1) torrent.Add("peers replaced", 1)
if !replaced.Equal(p) { if !replaced.Equal(p) {
t.logger.Printf("added %v replacing %v", p, replaced) t.logger.WithDefaultLevel(log.Debug).Printf("added %v replacing %v", p, replaced)
added = true added = true
} }
} else { } else {
@ -1343,7 +1343,7 @@ func (t *Torrent) startScrapingTracker(_url string) {
go func() { go func() {
err := wst.TrackerClient.Run(ar, u.String()) err := wst.TrackerClient.Run(ar, u.String())
if err != nil { if err != nil {
t.logger.WithDefaultLevel(log.Error).Printf( t.logger.WithDefaultLevel(log.Warning).Printf(
"error running websocket tracker announcer for %q: %v", "error running websocket tracker announcer for %q: %v",
u.String(), err) u.String(), err)
} }