Browse Source

add testing logger

pull/1842/head
Anton Kaliaev 8 years ago
parent
commit
520561e94a
No known key found for this signature in database GPG Key ID: 7B6881D965918214
1 changed files with 31 additions and 0 deletions
  1. +31
    -0
      log/testing_logger.go

+ 31
- 0
log/testing_logger.go View File

@ -0,0 +1,31 @@
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() {
_testingLogger = NewTMLogger(os.Stdout)
} else {
_testingLogger = NewNopLogger()
}
return _testingLogger
}

Loading…
Cancel
Save