From 45686f4df28a435d2f669cde96a3d1759a631177 Mon Sep 17 00:00:00 2001 From: Anton Novojilov Date: Mon, 8 Jul 2024 00:09:53 +0300 Subject: [PATCH] [log] Code refactoring --- CHANGELOG.md | 1 + log/log.go | 26 +++++++++++++------------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 96e76197..c6298d25 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 --- diff --git a/log/log.go b/log/log.go index 8d72141b..b1bb1d08 100644 --- a/log/log.go +++ b/log/log.go @@ -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