From 05e448d13292873877fb0b649bd0d153bd3e4b9f Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Mon, 13 Apr 2020 19:13:23 +1000 Subject: [PATCH] webtorrent logging improvements --- torrent.go | 6 ++++-- webtorrent/tracker_client.go | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/torrent.go b/torrent.go index a974db28..51a8cce5 100644 --- a/torrent.go +++ b/torrent.go @@ -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 diff --git a/webtorrent/tracker_client.go b/webtorrent/tracker_client.go index d66a54a2..8039e8ce 100644 --- a/webtorrent/tracker_client.go +++ b/webtorrent/tracker_client.go @@ -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 { -- 2.44.0