mirror of
https://github.com/fluencelabs/tendermint
synced 2025-05-21 18:41:18 +00:00
Merge pull request #14 from tendermint/feature/allow-for-custom-color-functions
[log] allow for custom color funcs
This commit is contained in:
commit
4fdeaa70af
@ -3,6 +3,8 @@ package log
|
|||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/go-kit/kit/log/term"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -29,3 +31,19 @@ func TestingLogger() Logger {
|
|||||||
|
|
||||||
return _testingLogger
|
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
|
||||||
|
}
|
||||||
|
@ -43,6 +43,12 @@ func NewTMLogger(w io.Writer) Logger {
|
|||||||
return &tmLogger{term.NewLogger(w, NewTMFmtLogger, colorFn)}
|
return &tmLogger{term.NewLogger(w, NewTMFmtLogger, colorFn)}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewTMLoggerWithColorFn allow you to provide your own color function. See
|
||||||
|
// NewTMLogger for documentation.
|
||||||
|
func NewTMLoggerWithColorFn(w io.Writer, colorFn func(keyvals ...interface{}) term.FgBgColor) Logger {
|
||||||
|
return &tmLogger{term.NewLogger(w, NewTMFmtLogger, colorFn)}
|
||||||
|
}
|
||||||
|
|
||||||
// Info logs a message at level Info.
|
// Info logs a message at level Info.
|
||||||
func (l *tmLogger) Info(msg string, keyvals ...interface{}) error {
|
func (l *tmLogger) Info(msg string, keyvals ...interface{}) error {
|
||||||
lWithLevel := kitlevel.Info(l.srcLogger)
|
lWithLevel := kitlevel.Info(l.srcLogger)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user