From 2302436ebe5874faa8a79f215a18dd77b2791db8 Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Wed, 9 Apr 2025 15:03:36 +1000 Subject: [PATCH] Add infohash to torrent logger --- client.go | 2 +- t.go | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) 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() } -- 2.48.1