tendermint/log/testing_logger.go

32 lines
643 B
Go
Raw Normal View History

2017-05-03 00:06:30 -07:00
package log
import (
"os"
"testing"
)
var (
// reuse the same logger across all tests
_testingLogger Logger
)
// TestingLogger returns a TMLogger which writes to STDOUT if testing being run
// with the verbose (-v) flag, NopLogger otherwise.
//
// Note that the call to TestingLogger() must be made
// inside a test (not in the init func) because
// verbose flag only set at the time of testing.
func TestingLogger() Logger {
if _testingLogger != nil {
return _testingLogger
}
if testing.Verbose() {
2017-05-04 08:39:16 -07:00
_testingLogger = NewTMLogger(NewSyncWriter(os.Stdout))
2017-05-03 00:06:30 -07:00
} else {
_testingLogger = NewNopLogger()
}
return _testingLogger
}