[#224] Refactor logger tag configuration
All checks were successful
/ DCO (pull_request) Successful in 29s
/ Vulncheck (pull_request) Successful in 48s
/ Builds (pull_request) Successful in 1m21s
/ OCI image (pull_request) Successful in 1m55s
/ Lint (pull_request) Successful in 1m54s
/ Tests (pull_request) Successful in 51s
/ Integration tests (pull_request) Successful in 7m12s
/ Builds (push) Successful in 1m10s
/ Vulncheck (push) Successful in 1m5s
/ Lint (push) Successful in 3m8s
/ Tests (push) Successful in 1m9s
/ Integration tests (push) Successful in 5m51s
/ OCI image (push) Successful in 1m3s

Signed-off-by: Pavel Pogodaev <p.pogodaev@yadro.com>
This commit is contained in:
Pavel Pogodaev 2025-03-21 13:38:43 +03:00
parent f0b86c8ba7
commit cb72d11515
7 changed files with 59 additions and 28 deletions

View file

@ -113,7 +113,7 @@ const (
cfgLoggerTags = "logger.tags"
cfgLoggerTagsPrefixTmpl = cfgLoggerTags + ".%d."
cfgLoggerTagsNameTmpl = cfgLoggerTagsPrefixTmpl + "name"
cfgLoggerTagsNameTmpl = cfgLoggerTagsPrefixTmpl + "names"
cfgLoggerTagsLevelTmpl = cfgLoggerTagsPrefixTmpl + "level"
// Wallet.
@ -516,8 +516,8 @@ func fetchLogTagsConfig(v *viper.Viper, defaultLvl zapcore.Level) (map[string]za
res := make(map[string]zapcore.Level)
for i := 0; ; i++ {
name := v.GetString(fmt.Sprintf(cfgLoggerTagsNameTmpl, i))
if name == "" {
tagNames := v.GetString(fmt.Sprintf(cfgLoggerTagsNameTmpl, i))
if tagNames == "" {
break
}
@ -529,7 +529,12 @@ func fetchLogTagsConfig(v *viper.Viper, defaultLvl zapcore.Level) (map[string]za
}
}
res[name] = lvl
for _, tagName := range strings.Split(tagNames, ",") {
tagName = strings.TrimSpace(tagName)
if len(tagName) != 0 {
res[tagName] = lvl
}
}
}
if len(res) == 0 && !v.IsSet(cfgLoggerTags) {