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