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:
1 parent
90fb201a51
commit
1b57a24789
1 file changed
+5
@@ -19,6 +19,7 @@ var (
|
|||||||
Info *log.Logger
|
Info *log.Logger
|
||||||
Warning *log.Logger
|
Warning *log.Logger
|
||||||
Error *log.Logger
|
Error *log.Logger
|
||||||
|
debugF bool
|
||||||
)
|
)
|
||||||
|
|
||||||
func InitLogging(debugHandle io.Writer,
|
func InitLogging(debugHandle io.Writer,
|
||||||
@@ -33,6 +34,10 @@ func InitLogging(debugHandle io.Writer,
|
|||||||
}
|
}
|
||||||
|
|
||||||
func InitDefaultLogging(debug bool) {
|
func InitDefaultLogging(debug bool) {
|
||||||
|
if debug == debugF {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
debugF = debug
|
||||||
debugOut := ioutil.Discard
|
debugOut := ioutil.Discard
|
||||||
if debug {
|
if debug {
|
||||||
debugOut = os.Stderr
|
debugOut = os.Stderr
|
||||||
|
|||||||
Reference in new issue
Block a user