Skip to content

Commit

Permalink
[log] Code refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
andyone committed Jul 7, 2024
1 parent a37d04f commit 45686f4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- `[knf/validators]` Validator `NotPrefix` renamed to `NotPrefix`
- `[knf/validators]` Validator `HasSuffix` renamed to `HasSuffix`
- `[knf/validators]` Validator `Equals` renamed to `NotEquals`
- `[log]` Code refactoring

---

Expand Down
26 changes: 13 additions & 13 deletions log/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -765,32 +765,32 @@ func (l *Logger) writeJSONField(field Field) {
// convertMinLevelValue converts any supported format of minimal level to uint8 used
// for default levels
func convertMinLevelValue(level any) (uint8, error) {
switch u := level.(type) {
switch t := level.(type) {
case int:
return uint8(u), nil
return uint8(t), nil
case int8:
return uint8(u), nil
return uint8(t), nil
case int16:
return uint8(u), nil
return uint8(t), nil
case int32:
return uint8(u), nil
return uint8(t), nil
case int64:
return uint8(u), nil
return uint8(t), nil
case uint:
return uint8(u), nil
return uint8(t), nil
case uint8:
return uint8(u), nil
return uint8(t), nil
case uint16:
return uint8(u), nil
return uint8(t), nil
case uint32:
return uint8(u), nil
return uint8(t), nil
case uint64:
return uint8(u), nil
return uint8(t), nil
case string:
code, ok := logLevelsNames[strings.ToLower(level.(string))]
code, ok := logLevelsNames[strings.ToLower(t)]

if !ok {
return 255, errors.New("Unknown level " + level.(string))
return 255, errors.New("Unknown level " + t)
}

return code, nil
Expand Down

0 comments on commit 45686f4

Please sign in to comment.