parsing CAPS log levels (#506)

This commit is contained in:
Pavel Gryaznov 2022-11-11 14:15:40 +01:00 committed by GitHub
parent 5bdc93f7eb
commit 3543e9d94b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

3
log.go
View File

@ -105,6 +105,7 @@ import (
"io/ioutil" "io/ioutil"
"os" "os"
"strconv" "strconv"
"strings"
) )
// Level defines log levels. // Level defines log levels.
@ -160,7 +161,7 @@ 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 levelStr { switch strings.ToLower(levelStr) {
case LevelFieldMarshalFunc(TraceLevel): case LevelFieldMarshalFunc(TraceLevel):
return TraceLevel, nil return TraceLevel, nil
case LevelFieldMarshalFunc(DebugLevel): case LevelFieldMarshalFunc(DebugLevel):