7 "github.com/go-kit/kit/log/term"
11 // reuse the same logger across all tests
15 // TestingLogger returns a TMLogger which writes to STDOUT if testing being run
16 // with the verbose (-v) flag, NopLogger otherwise.
18 // Note that the call to TestingLogger() must be made
19 // inside a test (not in the init func) because
20 // verbose flag only set at the time of testing.
21 func TestingLogger() Logger {
22 if _testingLogger != nil {
26 if testing.Verbose() {
27 _testingLogger = NewTMLogger(NewSyncWriter(os.Stdout))
29 _testingLogger = NewNopLogger()
35 // TestingLoggerWithColorFn allow you to provide your own color function. See
36 // TestingLogger for documentation.
37 func TestingLoggerWithColorFn(colorFn func(keyvals ...interface{}) term.FgBgColor) Logger {
38 if _testingLogger != nil {
42 if testing.Verbose() {
43 _testingLogger = NewTMLoggerWithColorFn(NewSyncWriter(os.Stdout), colorFn)
45 _testingLogger = NewNopLogger()