Logger interface and tmLogger impl based on go-kit

This commit is contained in:
Anton Kaliaev
2017-04-27 13:42:03 +04:00
parent 706b9fbd67
commit ed76afd409
14 changed files with 473 additions and 68 deletions

27
log/logger.go Normal file
View File

@ -0,0 +1,27 @@
package log
import (
"fmt"
kitlog "github.com/go-kit/kit/log"
)
// Logger is what any Tendermint library should take.
type Logger interface {
Debug(msg string, keyvals ...interface{}) error
Info(msg string, keyvals ...interface{}) error
Error(msg string, keyvals ...interface{}) error
}
// With returns a new contextual logger with keyvals prepended to those passed
// to calls to Info, Debug or Error.
func With(logger Logger, keyvals ...interface{}) Logger {
switch logger.(type) {
case *tmLogger:
return &tmLogger{kitlog.With(logger.(*tmLogger).srcLogger, keyvals...)}
case *nopLogger:
return logger
default:
panic(fmt.Sprintf("Unexpected logger of type %T", logger))
}
}