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