From 8323dd9a14fedde3712f0b2e6cd2b1f30ab2285c Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Sat, 4 Jan 2020 16:40:51 +1100 Subject: [PATCH] cmd/torrent: Move log setup earlier to avoid race --- cmd/torrent/main.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/torrent/main.go b/cmd/torrent/main.go index b0beba21..d1be30c8 100644 --- a/cmd/torrent/main.go +++ b/cmd/torrent/main.go @@ -183,6 +183,9 @@ func main() { func mainErr() error { tagflag.Parse(&flags) defer envpprof.Stop() + if stdoutAndStderrAreSameFile() { + log.Default = log.Logger{log.StreamLogger{W: progress.Bypass(), Fmt: log.LineFormatter}} + } clientConfig := torrent.NewDefaultClientConfig() clientConfig.NoDHT = !flags.Dht clientConfig.Debug = flags.Debug @@ -234,9 +237,6 @@ func mainErr() error { http.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) { client.WriteStatus(w) }) - if stdoutAndStderrAreSameFile() { - log.SetDefault(log.Logger{log.StreamLogger{W: progress.Bypass(), Fmt: log.LineFormatter}}) - } if flags.Progress { progress.Start() }