forked from TrueCloudLab/frostfs-node
c645781b98
Create `logger` sub-package of `config` package. Implement `LoggerSection` type of logger sub-section. Add `Level` method to read logger level config value. Default level is `info`. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
33 lines
725 B
Go
33 lines
725 B
Go
package loggerconfig
|
|
|
|
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".
|
|
//
|
|
// Returns LevelDefault if value is not a non-empty string.
|
|
func (x *LoggerSection) Level() string {
|
|
v := config.StringSafe((*config.Config)(x), "level")
|
|
if v != "" {
|
|
return v
|
|
}
|
|
|
|
return LevelDefault
|
|
}
|