From 71a9794222c37269ba4fa37801c34851db657969 Mon Sep 17 00:00:00 2001
From: Pavel Pogodaev
Date: Fri, 21 Mar 2025 13:38:43 +0300
Subject: [PATCH] [] Refactor logger tag configuration
Signed-off-by: Pavel Pogodaev
---
cmd/http-gw/settings.go | 10 ++++++----
config/config.yaml | 3 +--
docs/gate-configuration.md | 15 +++++++--------
3 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/cmd/http-gw/settings.go b/cmd/http-gw/settings.go
index 69ecce2..ec26339 100644
--- a/cmd/http-gw/settings.go
+++ b/cmd/http-gw/settings.go
@@ -112,7 +112,7 @@ const (
cfgLoggerTags = "logger.tags"
cfgLoggerTagsPrefixTmpl = cfgLoggerTags + ".%d."
- cfgLoggerTagsNameTmpl = cfgLoggerTagsPrefixTmpl + "name"
+ cfgLoggerTagsNameTmpl = cfgLoggerTagsPrefixTmpl + "names"
cfgLoggerTagsLevelTmpl = cfgLoggerTagsPrefixTmpl + "level"
// Wallet.
@@ -509,8 +509,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
}
@@ -522,7 +522,9 @@ func fetchLogTagsConfig(v *viper.Viper, defaultLvl zapcore.Level) (map[string]za
}
}
- res[name] = lvl
+ for _, tagName := range strings.Split(tagNames, ",") {
+ res[tagName] = lvl
+ }
}
if len(res) == 0 && !v.IsSet(cfgLoggerTags) {
diff --git a/config/config.yaml b/config/config.yaml
index 8c51591..3a50607 100644
--- a/config/config.yaml
+++ b/config/config.yaml
@@ -30,8 +30,7 @@ logger:
thereafter: 100
interval: 1s
tags:
- - name: app
- - name: datapath
+ - names: app,datapath
level: debug
server:
diff --git a/docs/gate-configuration.md b/docs/gate-configuration.md
index 191e9bb..72721c5 100644
--- a/docs/gate-configuration.md
+++ b/docs/gate-configuration.md
@@ -175,10 +175,9 @@ logger:
thereafter: 100
interval: 1s
tags:
- - name: "app"
+ - names: "app,datapath"
level: info
- - name: "datapath"
- - name: "external_storage_tree"
+ - names: "external_storage_tree"
```
| Parameter | Type | SIGHUP reload | Default value | Description |
@@ -198,14 +197,14 @@ parameter. Available tags:
```yaml
tags:
- - name: "app"
+ - names: "app,datapath"
level: info
```
-| Parameter | Type | SIGHUP reload | Default value | Description |
-|-----------------------|------------|---------------|---------------------------|-------------------------------------------------------------------------------------------------------|
-| `name` | `string` | yes | | Tag name. Possible values see below in `Tag values` section. |
-| `level` | `string` | yes | Value from `logger.level` | Logging level for specific tag. Possible values: `debug`, `info`, `warn`, `dpanic`, `panic`, `fatal`. |
+| Parameter | Type | SIGHUP reload | Default value | Description |
+|-----------|------------|---------------|---------------------------|-------------------------------------------------------------------------------------------------------|
+| `names` | `[]string` | yes | | Tag names separated by `,`. Possible values see below in `Tag values` section. |
+| `level` | `string` | yes | Value from `logger.level` | Logging level for specific tag. Possible values: `debug`, `info`, `warn`, `dpanic`, `panic`, `fatal`. |
### Tag values