From a9102abf1d453a78e0e3dbbcc0cbb2d48cdb9ff6 Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Sat, 10 Oct 2020 10:24:58 +1100 Subject: [PATCH] Tidy up some logging --- client.go | 4 ++-- peerconn.go | 4 ++-- pexconn.go | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/client.go b/client.go index 682cf836..9bd16610 100644 --- a/client.go +++ b/client.go @@ -1350,14 +1350,14 @@ func (cl *Client) newConnection(nc net.Conn, outgoing bool, remoteAddr net.Addr, writeBuffer: new(bytes.Buffer), } c.peerImpl = c - c.logger = cl.logger.WithDefaultLevel(log.Debug).WithContextValue(c) + c.logger = cl.logger.WithDefaultLevel(log.Warning).WithContextValue(c) c.writerCond.L = cl.locker() c.setRW(connStatsReadWriter{nc, c}) c.r = &rateLimitedReader{ l: cl.config.DownloadRateLimiter, r: c.r, } - c.logger.Printf("initialized with remote %v over network %v (outgoing=%t)", remoteAddr, network, outgoing) + c.logger.WithDefaultLevel(log.Debug).Printf("initialized with remote %v over network %v (outgoing=%t)", remoteAddr, network, outgoing) return } diff --git a/peerconn.go b/peerconn.go index 4cbe40bb..06537c9f 100644 --- a/peerconn.go +++ b/peerconn.go @@ -1341,7 +1341,7 @@ func (c *peer) receiveChunk(msg *pp.Message) error { piece.decrementPendingWrites() if err != nil { - c.logger.Printf("error writing received chunk %v: %v", req, err) + c.logger.WithDefaultLevel(log.Error).Printf("writing received chunk %v: %v", req, err) t.pendRequest(req) //t.updatePieceCompletion(pieceIndex(msg.Index)) t.onWriteChunkErr(err) @@ -1553,7 +1553,7 @@ func (c *PeerConn) setTorrent(t *Torrent) { panic("connection already associated with a torrent") } c.t = t - c.logger.Printf("torrent=%v", t) + c.logger.WithDefaultLevel(log.Debug).Printf("set torrent=%v", t) t.reconcileHandshakeStats(c) } diff --git a/pexconn.go b/pexconn.go index dcb3136c..57ec7ff5 100644 --- a/pexconn.go +++ b/pexconn.go @@ -41,8 +41,8 @@ func (s *pexConnState) Init(c *PeerConn) { s.xid = xid s.seq = 0 s.torrent = c.t - s.info = c.t.cl.logger - s.dbg = c.logger + s.info = c.t.cl.logger.WithDefaultLevel(log.Info) + s.dbg = c.logger.WithDefaultLevel(log.Debug) s.readyfn = c.tickleWriter s.gate = make(chan struct{}, 1) s.timer = time.AfterFunc(0, func() {