]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Add infohash to torrent logger
authorMatt Joiner <anacrolix@gmail.com>
Wed, 9 Apr 2025 05:03:36 +0000 (15:03 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Wed, 9 Apr 2025 05:03:36 +0000 (15:03 +1000)
client.go
t.go

index 869161441d63093dbaf982db2217c36b3c6e5299..ffaff0d55f743767cb4f6893e88d1bfcbfed3732 100644 (file)
--- a/client.go
+++ b/client.go
@@ -1377,7 +1377,7 @@ func (cl *Client) newTorrentOpt(opts AddTorrentOpts) (t *Torrent) {
        }
        t.smartBanCache.Init()
        t.networkingEnabled.Set()
-       t.logger = cl.logger.WithDefaultLevel(log.Debug)
+       t.logger = cl.logger.WithDefaultLevel(log.Debug).WithNames(t.InfoHash().HexString())
        t.sourcesLogger = t.logger.WithNames("sources")
        if opts.ChunkSize == 0 {
                opts.ChunkSize = defaultChunkSize
diff --git a/t.go b/t.go
index 219656a6ce52d67d06ecfbe6bd77868342770a30..6ec484b6fb783d587ccaa02f4c6ee5c93da84c56 100644 (file)
--- a/t.go
+++ b/t.go
@@ -11,7 +11,9 @@ import (
        "github.com/anacrolix/torrent/metainfo"
 )
 
-// The Torrent's infohash. This is fixed and cannot change. It uniquely identifies a torrent.
+// The Torrent's infohash. This is fixed and cannot change. It uniquely
+// identifies a torrent. TODO: If this doesn't change, should we stick to
+// referring to a Torrent by the original infohash given to us?
 func (t *Torrent) InfoHash() metainfo.Hash {
        return *t.canonicalShortInfohash()
 }