From: Matt Joiner Date: Wed, 9 Apr 2025 05:03:36 +0000 (+1000) Subject: Add infohash to torrent logger X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=2302436ebe5874faa8a79f215a18dd77b2791db8;p=btrtrc.git Add infohash to torrent logger --- diff --git a/client.go b/client.go index 86916144..ffaff0d5 100644 --- 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 219656a6..6ec484b6 100644 --- 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() }