diff --git a/cmd/neofs-node/config/logger/config.go b/cmd/neofs-node/config/logger/config.go index 479bf97c8..e443020ed 100644 --- a/cmd/neofs-node/config/logger/config.go +++ b/cmd/neofs-node/config/logger/config.go @@ -4,27 +4,21 @@ import ( "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config" ) -// LoggerSection represents config section -// for logging component. -type LoggerSection config.Config - // config defaults const ( // LevelDefault is a default logger level LevelDefault = "info" ) -// Init initializes LoggerSection from -// "logger" subsection of config. -func Init(root *config.Config) *LoggerSection { - return (*LoggerSection)(root.Sub("logger")) -} - -// Level returns configuration value with name "level". +// Level returns value of "level" config parameter +// from "logger" section. // // Returns LevelDefault if value is not a non-empty string. -func (x *LoggerSection) Level() string { - v := config.StringSafe((*config.Config)(x), "level") +func Level(c *config.Config) string { + v := config.StringSafe( + c.Sub("logger"), + "level", + ) if v != "" { return v } diff --git a/cmd/neofs-node/config/logger/config_test.go b/cmd/neofs-node/config/logger/config_test.go index 6258bed9b..fbdea6555 100644 --- a/cmd/neofs-node/config/logger/config_test.go +++ b/cmd/neofs-node/config/logger/config_test.go @@ -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) }) }