]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Include torrent info hash as logger context text
authorMatt Joiner <anacrolix@gmail.com>
Thu, 24 Apr 2025 13:06:15 +0000 (23:06 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Thu, 24 Apr 2025 13:08:39 +0000 (23:08 +1000)
client.go

index 34a516442a65d236863c5eedb4227f106eb0255d..99266c50ac1d22937d52d06459cadd55dd7b1117 100644 (file)
--- a/client.go
+++ b/client.go
@@ -1384,7 +1384,8 @@ func (cl *Client) newTorrentOpt(opts AddTorrentOpts) (t *Torrent) {
        }
        t.smartBanCache.Init()
        t.networkingEnabled.Set()
-       t.logger = cl.logger.WithDefaultLevel(log.Debug).WithNames(t.InfoHash().HexString())
+       ihHex := t.InfoHash().HexString()
+       t.logger = cl.logger.WithDefaultLevel(log.Debug).WithNames(ihHex).WithContextText(ihHex)
        t.sourcesLogger = t.logger.WithNames("sources")
        if opts.ChunkSize == 0 {
                opts.ChunkSize = defaultChunkSize