set the global debug flag 'Debug' for and only for torrent module

This commit is contained in:
whr819987540 2023-05-08 11:29:28 +08:00
parent bc82214838
commit 9a636d2326
1 changed files with 6 additions and 1 deletions

View File

@ -23,8 +23,8 @@ import (
"github.com/anacrolix/chansync/events" "github.com/anacrolix/chansync/events"
"github.com/anacrolix/dht/v2" "github.com/anacrolix/dht/v2"
"github.com/anacrolix/dht/v2/krpc" "github.com/anacrolix/dht/v2/krpc"
g "github.com/anacrolix/generics"
. "github.com/anacrolix/generics" . "github.com/anacrolix/generics"
g "github.com/anacrolix/generics"
"github.com/anacrolix/log" "github.com/anacrolix/log"
"github.com/anacrolix/missinggo/perf" "github.com/anacrolix/missinggo/perf"
"github.com/anacrolix/missinggo/v2" "github.com/anacrolix/missinggo/v2"
@ -50,6 +50,10 @@ import (
"github.com/anacrolix/torrent/webtorrent" "github.com/anacrolix/torrent/webtorrent"
) )
var (
Debug = false
)
// Clients contain zero or more Torrents. A Client manages a blocklist, the // Clients contain zero or more Torrents. A Client manages a blocklist, the
// TCP/UDP protocol ports, and DHT as desired. // TCP/UDP protocol ports, and DHT as desired.
type Client struct { type Client struct {
@ -178,6 +182,7 @@ func (cl *Client) WriteStatus(_w io.Writer) {
} }
func (cl *Client) initLogger() { func (cl *Client) initLogger() {
Debug = cl.config.Debug // set the global debug flag for and only for torrent module
logger := cl.config.Logger logger := cl.config.Logger
if logger.IsZero() { if logger.IsZero() {
logger = log.Default logger = log.Default