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.
This commit is contained in:
Bryan Boreham committed 2015-06-17 11:35:01 +01:00
1 parent 90fb201a51
commit 1b57a24789
1 file changed
+5
+5
View File
@@ -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