Tidy up some logging

This commit is contained in:
Matt Joiner 2020-10-10 10:24:58 +11:00
parent d3daaaf75a
commit a9102abf1d
3 changed files with 6 additions and 6 deletions

View File

@ -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
}

View File

@ -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)
}

View File

@ -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() {