mirror of
https://github.com/tendermint/tendermint.git
synced 2025-12-23 14:25:19 +00:00
* build(deps): Bump github.com/go-kit/kit from 0.10.0 to 0.12.0 Bumps [github.com/go-kit/kit](https://github.com/go-kit/kit) from 0.10.0 to 0.12.0. - [Release notes](https://github.com/go-kit/kit/releases) - [Commits](https://github.com/go-kit/kit/compare/v0.10.0...v0.12.0) --- updated-dependencies: - dependency-name: github.com/go-kit/kit dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * add nolint * fix lint * fix build Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: tycho garen <garen@tychoish.com>
61 lines
1.5 KiB
Go
61 lines
1.5 KiB
Go
package log
|
|
|
|
import (
|
|
"io"
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/go-kit/log/term"
|
|
)
|
|
|
|
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 {
|
|
return TestingLoggerWithOutput(os.Stdout)
|
|
}
|
|
|
|
// TestingLoggerWOutput returns a TMLogger which writes to (w io.Writer) if testing being run
|
|
// with the verbose (-v) flag, NopLogger otherwise.
|
|
//
|
|
// Note that the call to TestingLoggerWithOutput(w io.Writer) must be made
|
|
// inside a test (not in the init func) because
|
|
// verbose flag only set at the time of testing.
|
|
func TestingLoggerWithOutput(w io.Writer) Logger {
|
|
if _testingLogger != nil {
|
|
return _testingLogger
|
|
}
|
|
|
|
if testing.Verbose() {
|
|
_testingLogger = NewTMLogger(NewSyncWriter(w))
|
|
} else {
|
|
_testingLogger = NewNopLogger()
|
|
}
|
|
|
|
return _testingLogger
|
|
}
|
|
|
|
// TestingLoggerWithColorFn allow you to provide your own color function. See
|
|
// TestingLogger for documentation.
|
|
func TestingLoggerWithColorFn(colorFn func(keyvals ...interface{}) term.FgBgColor) Logger {
|
|
if _testingLogger != nil {
|
|
return _testingLogger
|
|
}
|
|
|
|
if testing.Verbose() {
|
|
_testingLogger = NewTMLoggerWithColorFn(NewSyncWriter(os.Stdout), colorFn)
|
|
} else {
|
|
_testingLogger = NewNopLogger()
|
|
}
|
|
|
|
return _testingLogger
|
|
}
|