Archived
2
0

apply debug from env.

This commit is contained in:
Miroslav Šedivý 2021-05-23 19:18:57 +02:00
parent e47fa91381
commit ce42d81eeb

View File

@ -36,16 +36,11 @@ func init() {
zerolog.TimeFieldFormat = ""
zerolog.SetGlobalLevel(zerolog.InfoLevel)
if viper.GetBool("debug") {
zerolog.SetGlobalLevel(zerolog.DebugLevel)
}
console := zerolog.ConsoleWriter{Out: os.Stdout}
if !viper.GetBool("logs") {
log.Logger = log.Output(console)
} else {
logs := filepath.Join(".", "logs")
if runtime.GOOS == "linux" {
logs = "/var/log/neko"
@ -103,9 +98,14 @@ func init() {
}
}
debug := viper.GetBool("debug")
if debug {
zerolog.SetGlobalLevel(zerolog.DebugLevel)
}
file := viper.ConfigFileUsed()
logger := log.With().
Bool("debug", viper.GetBool("debug")).
Bool("debug", debug).
Str("logging", viper.GetString("logs")).
Str("config", file).
Logger()