From 1b57a247894bdd8f1ea6f36ce8901ae82b8bce9d Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Tue, 16 Jun 2015 16:51:19 +0100 Subject: [PATCH] Don't re-initialise log writers unless the type changed. This avoids race-conditions in unit tests where the initialisation is on a different goroutine to the logging. --- common/logging.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/common/logging.go b/common/logging.go index 6c3f5627..8def1602 100644 --- a/common/logging.go +++ b/common/logging.go @@ -19,6 +19,7 @@ var ( Info *log.Logger Warning *log.Logger Error *log.Logger + debugF bool ) func InitLogging(debugHandle io.Writer, @@ -33,6 +34,10 @@ func InitLogging(debugHandle io.Writer, } func InitDefaultLogging(debug bool) { + if debug == debugF { + return + } + debugF = debug debugOut := ioutil.Discard if debug { debugOut = os.Stderr