fix level parser (#523)
This commit is contained in:
parent
4fff5db29c
commit
902d72012d
20
log.go
20
log.go
|
@ -161,24 +161,24 @@ func (l Level) String() string {
|
||||||
// ParseLevel converts a level string into a zerolog Level value.
|
// ParseLevel converts a level string into a zerolog Level value.
|
||||||
// returns an error if the input string does not match known values.
|
// returns an error if the input string does not match known values.
|
||||||
func ParseLevel(levelStr string) (Level, error) {
|
func ParseLevel(levelStr string) (Level, error) {
|
||||||
switch strings.ToLower(levelStr) {
|
switch {
|
||||||
case LevelFieldMarshalFunc(TraceLevel):
|
case strings.EqualFold(levelStr, LevelFieldMarshalFunc(TraceLevel)):
|
||||||
return TraceLevel, nil
|
return TraceLevel, nil
|
||||||
case LevelFieldMarshalFunc(DebugLevel):
|
case strings.EqualFold(levelStr, LevelFieldMarshalFunc(DebugLevel)):
|
||||||
return DebugLevel, nil
|
return DebugLevel, nil
|
||||||
case LevelFieldMarshalFunc(InfoLevel):
|
case strings.EqualFold(levelStr, LevelFieldMarshalFunc(InfoLevel)):
|
||||||
return InfoLevel, nil
|
return InfoLevel, nil
|
||||||
case LevelFieldMarshalFunc(WarnLevel):
|
case strings.EqualFold(levelStr, LevelFieldMarshalFunc(WarnLevel)):
|
||||||
return WarnLevel, nil
|
return WarnLevel, nil
|
||||||
case LevelFieldMarshalFunc(ErrorLevel):
|
case strings.EqualFold(levelStr, LevelFieldMarshalFunc(ErrorLevel)):
|
||||||
return ErrorLevel, nil
|
return ErrorLevel, nil
|
||||||
case LevelFieldMarshalFunc(FatalLevel):
|
case strings.EqualFold(levelStr, LevelFieldMarshalFunc(FatalLevel)):
|
||||||
return FatalLevel, nil
|
return FatalLevel, nil
|
||||||
case LevelFieldMarshalFunc(PanicLevel):
|
case strings.EqualFold(levelStr, LevelFieldMarshalFunc(PanicLevel)):
|
||||||
return PanicLevel, nil
|
return PanicLevel, nil
|
||||||
case LevelFieldMarshalFunc(Disabled):
|
case strings.EqualFold(levelStr, LevelFieldMarshalFunc(Disabled)):
|
||||||
return Disabled, nil
|
return Disabled, nil
|
||||||
case LevelFieldMarshalFunc(NoLevel):
|
case strings.EqualFold(levelStr, LevelFieldMarshalFunc(NoLevel)):
|
||||||
return NoLevel, nil
|
return NoLevel, nil
|
||||||
}
|
}
|
||||||
i, err := strconv.Atoi(levelStr)
|
i, err := strconv.Atoi(levelStr)
|
||||||
|
|
Loading…
Reference in New Issue