Respect the debug flag in the environment
This commit is contained in:
parent
7d071ebe0b
commit
fbd655b2da
@ -10,6 +10,7 @@ var (
|
||||
|
||||
type (
|
||||
Config struct {
|
||||
Debug bool `mapstructure:"debug"`
|
||||
Handler HandlerConfig `mapstructure:"handler"`
|
||||
Prefix string `mapstructure:"prefix"`
|
||||
DiscordToken string `mapstructure:"discord_token"`
|
||||
|
@ -83,10 +83,6 @@ func setupConfig() {
|
||||
pflag.Parse()
|
||||
viper.BindPFlags(pflag.CommandLine)
|
||||
|
||||
if viper.GetBool("debug") {
|
||||
log.SetLevel(log.DebugLevel)
|
||||
}
|
||||
|
||||
viper.SetEnvPrefix("BEEPBOOP")
|
||||
viper.AutomaticEnv()
|
||||
|
||||
@ -96,6 +92,7 @@ func setupConfig() {
|
||||
|
||||
err = viper.ReadInConfig()
|
||||
|
||||
viper.BindEnv("DEBUG")
|
||||
viper.BindEnv("DISCORD_TOKEN")
|
||||
viper.BindEnv("OPEN_WEATHER_MAP_TOKEN")
|
||||
|
||||
@ -107,4 +104,8 @@ func setupConfig() {
|
||||
if err != nil {
|
||||
log.Fatalf("unable to decode into struct: %v", err)
|
||||
}
|
||||
|
||||
if viper.GetBool("debug") {
|
||||
log.SetLevel(log.DebugLevel)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user