|
|
@ -4,6 +4,7 @@ import ( |
|
|
|
"fmt" |
|
|
|
|
|
|
|
kitlog "github.com/go-kit/kit/log" |
|
|
|
"github.com/go-kit/kit/log/level" |
|
|
|
) |
|
|
|
|
|
|
|
// Logger is what any Tendermint library should take.
|
|
|
@ -25,3 +26,24 @@ func With(logger Logger, keyvals ...interface{}) Logger { |
|
|
|
panic(fmt.Sprintf("Unexpected logger of type %T", logger)) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// WithLevel returns a copy of the logger with a level set to lvl.
|
|
|
|
func WithLevel(logger Logger, lvl string) Logger { |
|
|
|
switch logger.(type) { |
|
|
|
case *tmLogger: |
|
|
|
switch lvl { |
|
|
|
case "info": |
|
|
|
return &tmLogger{level.NewFilter(logger.(*tmLogger).srcLogger, level.AllowInfo())} |
|
|
|
case "debug": |
|
|
|
return &tmLogger{level.NewFilter(logger.(*tmLogger).srcLogger, level.AllowDebug())} |
|
|
|
case "error": |
|
|
|
return &tmLogger{level.NewFilter(logger.(*tmLogger).srcLogger, level.AllowError())} |
|
|
|
default: |
|
|
|
panic(fmt.Sprintf("Unexpected level %v, expect either \"info\" or \"debug\" or \"error\"", lvl)) |
|
|
|
} |
|
|
|
case *nopLogger: |
|
|
|
return logger |
|
|
|
default: |
|
|
|
panic(fmt.Sprintf("Unexpected logger of type %T", logger)) |
|
|
|
} |
|
|
|
} |