]> Sergey Matveev's repositories - btrtrc.git/commitdiff
webtorrent logging improvements
authorMatt Joiner <anacrolix@gmail.com>
Mon, 13 Apr 2020 09:13:23 +0000 (19:13 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Mon, 13 Apr 2020 09:13:23 +0000 (19:13 +1000)
torrent.go
webtorrent/tracker_client.go

index a974db28d28fb813fe923643a877afa6d20f642f..51a8cce57a1efa4c577998f8b4de5b10324d8ff1 100644 (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
index d66a54a28ecffbc678cd2fc21876706a323d67d1..8039e8ce4af9ecf624d0705b271838ac7b6340be 100644 (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 {