ZRY fc0e63b0f5 General code maintenance job at 2022-11-08 17:27 1 year ago
..
README.md fc0e63b0f5 General code maintenance job at 2022-11-08 17:27 1 year ago
default_config_sample.go 8286ca9414 Fix bug: indent mistake in yamlutil sample config 3 years ago
go.mod 311fe527fc Tidy go module at 2022-11-08 16:06 1 year ago
go.sum 311fe527fc Tidy go module at 2022-11-08 16:06 1 year ago
simple_console_backend.go b03f1d6a12 Add Hostname Field @2020-06-11 14:12 4 years ago
yaml_def.go b03f1d6a12 Add Hostname Field @2020-06-11 14:12 4 years ago
yamlutil.go a9465fbad7 Fix bug: no need for CGO. @2020-06-11 14:12 4 years ago

README.md

Usage

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.")
}