[#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
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue