Use Torrent logger instead of default logger (#740)

This commit is contained in:
FIGBERT 2022-04-25 01:49:59 -07:00 committed by GitHub
parent 529d97b5eb
commit 2c8a3219db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 5 deletions

View File

@ -987,7 +987,7 @@ func (t *Torrent) hashPiece(piece pieceIndex) (
} }
_, err = storagePiece.WriteTo(io.MultiWriter(writers...)) _, err = storagePiece.WriteTo(io.MultiWriter(writers...))
if logPieceContents { if logPieceContents {
log.Printf("hashed %q with copy err %v", examineBuf.Bytes(), err) t.logger.WithDefaultLevel(log.Debug).Printf("hashed %q with copy err %v", examineBuf.Bytes(), err)
} }
smartBanWriter.Flush() smartBanWriter.Flush()
differingPeers = smartBanWriter.badPeers differingPeers = smartBanWriter.badPeers
@ -2151,20 +2151,20 @@ func (t *Torrent) dropBannedPeers() {
remoteIp := p.remoteIp() remoteIp := p.remoteIp()
if remoteIp == nil { if remoteIp == nil {
if p.bannableAddr.Ok() { if p.bannableAddr.Ok() {
log.Printf("can't get remote ip for peer %v", p) t.logger.WithDefaultLevel(log.Debug).Printf("can't get remote ip for peer %v", p)
} }
return return
} }
netipAddr := netip.MustParseAddr(remoteIp.String()) netipAddr := netip.MustParseAddr(remoteIp.String())
if Some(netipAddr) != p.bannableAddr { if Some(netipAddr) != p.bannableAddr {
log.Printf( t.logger.WithDefaultLevel(log.Debug).Printf(
"peer remote ip does not match its bannable addr [peer=%v, remote ip=%v, bannable addr=%v]", "peer remote ip does not match its bannable addr [peer=%v, remote ip=%v, bannable addr=%v]",
p, remoteIp, p.bannableAddr) p, remoteIp, p.bannableAddr)
} }
if _, ok := t.cl.badPeerIPs[netipAddr]; ok { if _, ok := t.cl.badPeerIPs[netipAddr]; ok {
// Should this be a close? // Should this be a close?
p.drop() p.drop()
log.Printf("dropped %v for banned remote IP %v", p, netipAddr) t.logger.WithDefaultLevel(log.Debug).Printf("dropped %v for banned remote IP %v", p, netipAddr)
} }
}) })
} }
@ -2184,7 +2184,7 @@ func (t *Torrent) pieceHasher(index pieceIndex) {
if correct { if correct {
for peer := range failedPeers { for peer := range failedPeers {
t.cl.banPeerIP(peer.AsSlice()) t.cl.banPeerIP(peer.AsSlice())
log.Printf("smart banned %v for piece %v", peer, index) t.logger.WithDefaultLevel(log.Debug).Printf("smart banned %v for piece %v", peer, index)
} }
t.dropBannedPeers() t.dropBannedPeers()
for ri := t.pieceRequestIndexOffset(index); ri < t.pieceRequestIndexOffset(index+1); ri++ { for ri := t.pieceRequestIndexOffset(index); ri < t.pieceRequestIndexOffset(index+1); ri++ {