ZRY fc0e63b0f5 General code maintenance job at 2022-11-08 17:27 | 1 year ago | |
---|---|---|
.. | ||
README.md | 1 year ago | |
default_config_sample.go | 3 years ago | |
go.mod | 1 year ago | |
go.sum | 1 year ago | |
simple_console_backend.go | 4 years ago | |
yaml_def.go | 4 years ago | |
yamlutil.go | 4 years ago |
Example code:
package example
import (
"git.swzry.com/zry/GoHiedaLogger/hieda_viper_util"
"git.swzry.com/zry/GoHiedaLogger/hiedalog"
"github.com/spf13/viper"
)
func main() {
viperCfg := viper.New()
// ...
logCfg := viperCfg.Sub("log.hieda")
// refer to viper's documentation.
logger := hiedalog.NewHiedaLogger()
// ...
vu := NewViperUtil(logger, logCfg)
// at the part of viper default config adding
viperCfg.SetDefault("example.key", "value")
// ...
vu.SetDefaults()
// ...
// the time to initialize the backends
vu.InitBackends()
//...
// then you can do your log
logger.LogString("example", hiedalog.DLN_INFO, "log example.")
}