Skip to content

Commit

Permalink
parsing CAPS log levels (#506)
Browse files Browse the repository at this point in the history
  • Loading branch information
GRbit authored Nov 11, 2022
1 parent 5bdc93f commit 3543e9d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion log.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ import (
"io/ioutil"
"os"
"strconv"
"strings"
)

// Level defines log levels.
Expand Down Expand Up @@ -160,7 +161,7 @@ func (l Level) String() string {
// ParseLevel converts a level string into a zerolog Level value.
// returns an error if the input string does not match known values.
func ParseLevel(levelStr string) (Level, error) {
switch levelStr {
switch strings.ToLower(levelStr) {
case LevelFieldMarshalFunc(TraceLevel):
return TraceLevel, nil
case LevelFieldMarshalFunc(DebugLevel):
Expand Down

1 comment on commit 3543e9d

@mvrahden
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually a problematic addition to the code base.

If one modifies the Global variables, i.e. Log Levels to be Upper case, there's no way to ever properly parse Upper Case levels, because the input is always transformed to lower case and the switch cases are all uppercase.

Please sign in to comment.