forked from TrueCloudLab/frostfs-node
[#493] node/config/logger: Simplify approach to read the level
Dedicated type `LoggerSection` turned out to be redundant since it doesn't do a hidden logic and just uses `config.Config` API. Remove `LoggerSection` type and implement `Level` which do the same. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
be6898a51d
commit
3b797d7957
2 changed files with 13 additions and 27 deletions
|
@ -12,20 +12,13 @@ import (
|
|||
)
|
||||
|
||||
func TestLoggerSection_Level(t *testing.T) {
|
||||
checkLevel := func(c *loggerconfig.LoggerSection, expected string) {
|
||||
lvl := c.Level()
|
||||
require.Equal(t, expected, lvl)
|
||||
}
|
||||
|
||||
configtest.ForEachFileType("../../../../config/example/node", func(c *config.Config) {
|
||||
cfg := loggerconfig.Init(c)
|
||||
|
||||
checkLevel(cfg, "debug")
|
||||
v := loggerconfig.Level(c)
|
||||
require.Equal(t, "debug", v)
|
||||
})
|
||||
|
||||
empty := loggerconfig.Init(configtest.EmptyConfig())
|
||||
|
||||
checkLevel(empty, loggerconfig.LevelDefault)
|
||||
v := loggerconfig.Level(configtest.EmptyConfig())
|
||||
require.Equal(t, loggerconfig.LevelDefault, v)
|
||||
|
||||
t.Run("ENV", func(t *testing.T) {
|
||||
// TODO: read from file
|
||||
|
@ -35,8 +28,7 @@ func TestLoggerSection_Level(t *testing.T) {
|
|||
)
|
||||
require.NoError(t, err)
|
||||
|
||||
empty = loggerconfig.Init(configtest.EmptyConfig())
|
||||
|
||||
checkLevel(empty, "debug")
|
||||
v := loggerconfig.Level(configtest.EmptyConfig())
|
||||
require.Equal(t, "debug", v)
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue