frostfs-node/cmd/neofs-node/config/logger/config.go
Leonard Lyubich 3b797d7957 [#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>
2021-06-01 11:45:38 +03:00

27 lines
475 B
Go

package loggerconfig
import (
"github.com/nspcc-dev/neofs-node/cmd/neofs-node/config"
)
// config defaults
const (
// LevelDefault is a default logger level
LevelDefault = "info"
)
// Level returns value of "level" config parameter
// from "logger" section.
//
// Returns LevelDefault if value is not a non-empty string.
func Level(c *config.Config) string {
v := config.StringSafe(
c.Sub("logger"),
"level",
)
if v != "" {
return v
}
return LevelDefault
}