mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-24 18:21:38 +00:00
[log] NewFilterByLevel returns an error
This commit is contained in:
@ -17,7 +17,8 @@ func NewFilter(next Logger, options ...Option) Logger {
|
||||
}
|
||||
|
||||
// NewFilterByLevel wraps next and implements filtering based on a given level.
|
||||
func NewFilterByLevel(next Logger, lvl string) Logger {
|
||||
// Error is returned if level is not info, error or debug.
|
||||
func NewFilterByLevel(next Logger, lvl string) (Logger, error) {
|
||||
var option Option
|
||||
switch lvl {
|
||||
case "info":
|
||||
@ -27,9 +28,9 @@ func NewFilterByLevel(next Logger, lvl string) Logger {
|
||||
case "error":
|
||||
option = AllowError()
|
||||
default:
|
||||
panic(fmt.Sprintf("Expected either \"info\", \"debug\" or \"error\" log level, given %v", lvl))
|
||||
return nil, fmt.Errorf("Expected either \"info\", \"debug\" or \"error\" log level, given %v", lvl)
|
||||
}
|
||||
return NewFilter(next, option)
|
||||
return NewFilter(next, option), nil
|
||||
}
|
||||
|
||||
type filter struct {
|
||||
|
Reference in New Issue
Block a user