Browse Source

[log] change helper func

pull/1842/head
Anton Kaliaev 8 years ago
parent
commit
d0cae7b6ed
No known key found for this signature in database GPG Key ID: 7B6881D965918214
1 changed files with 10 additions and 10 deletions
  1. +10
    -10
      log/filter.go

+ 10
- 10
log/filter.go View File

@ -17,21 +17,21 @@ func NewFilter(next Logger, options ...Option) Logger {
return l
}
// NewFilterByLevel wraps next and implements filtering based on a given level.
// Error is returned if level is not info, error or debug.
func NewFilterByLevel(next Logger, lvl string) (Logger, error) {
var option Option
// AllowLevel returns an option for the given level or error if no option exist
// for such level.
func AllowLevel(lvl string) (Option, error) {
switch lvl {
case "info":
option = AllowInfo()
case "debug":
option = AllowDebug()
return AllowDebug(), nil
case "info":
return AllowInfo(), nil
case "error":
option = AllowError()
return AllowError(), nil
case "none":
return AllowNone(), nil
default:
return nil, fmt.Errorf("Expected either \"info\", \"debug\" or \"error\" log level, given %v", lvl)
return nil, fmt.Errorf("Expected either \"info\", \"debug\", \"error\" or \"none\" level, given %s", lvl)
}
return NewFilter(next, option), nil
}
type filter struct {


Loading…
Cancel
Save