From 9a636d232651713517f96ee5f1d80158e2d57787 Mon Sep 17 00:00:00 2001 From: whr819987540 <819987540@qq.com> Date: Mon, 8 May 2023 11:29:28 +0800 Subject: [PATCH] set the global debug flag 'Debug' for and only for torrent module --- client.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/client.go b/client.go index c1e7709a..10f5b411 100644 --- a/client.go +++ b/client.go @@ -23,8 +23,8 @@ import ( "github.com/anacrolix/chansync/events" "github.com/anacrolix/dht/v2" "github.com/anacrolix/dht/v2/krpc" - g "github.com/anacrolix/generics" . "github.com/anacrolix/generics" + g "github.com/anacrolix/generics" "github.com/anacrolix/log" "github.com/anacrolix/missinggo/perf" "github.com/anacrolix/missinggo/v2" @@ -50,6 +50,10 @@ import ( "github.com/anacrolix/torrent/webtorrent" ) +var ( + Debug = false +) + // Clients contain zero or more Torrents. A Client manages a blocklist, the // TCP/UDP protocol ports, and DHT as desired. type Client struct { @@ -178,6 +182,7 @@ func (cl *Client) WriteStatus(_w io.Writer) { } func (cl *Client) initLogger() { + Debug = cl.config.Debug // set the global debug flag for and only for torrent module logger := cl.config.Logger if logger.IsZero() { logger = log.Default