webtorrent logging improvements

This commit is contained in:
Matt Joiner 2020-04-13 19:13:23 +10:00
parent 93366bb63a
commit 05e448d132
2 changed files with 6 additions and 4 deletions

View File

@ -1320,11 +1320,13 @@ func (t *Torrent) startScrapingTracker(_url string) {
wst := websocketTracker{*u, webtorrent.NewTrackerClient(t.cl.peerID, t.infoHash, t.onWebRtcConn,
t.logger.WithText(func(m log.Msg) string {
return fmt.Sprintf("%q: %v", u.String(), m.Text())
}))}
}).WithValues(log.Debug))}
go func() {
err := wst.TrackerClient.Run(t.announceRequest(tracker.Started), u.String())
if err != nil {
t.logger.WithValues(log.Error).Printf("error running websocket tracker announcer: %v", err)
t.logger.WithValues(log.Error).Printf(
"error running websocket tracker announcer for %q: %v",
u.String(), err)
}
}()
return wst

View File

@ -130,11 +130,11 @@ func (c *TrackerClient) trackerReadLoop() error {
var ar AnnounceResponse
if err := json.Unmarshal(message, &ar); err != nil {
log.Printf("error unmarshaling announce response: %v", err)
c.logger.Printf("error unmarshaling announce response: %v", err)
continue
}
if ar.InfoHash != c.infoHashBinary {
log.Printf("announce response for different hash: expected %q got %q", c.infoHashBinary, ar.InfoHash)
c.logger.Printf("announce response for different hash: expected %q got %q", c.infoHashBinary, ar.InfoHash)
continue
}
switch {