improve: 支持通过 flag 开启 debug 模式

This commit is contained in:
Mmx233
2023-06-01 18:36:39 +08:00
parent 4d4926add6
commit e895e6fe1d
2 changed files with 5 additions and 0 deletions

View File

@@ -9,10 +9,12 @@ var Flags struct {
Path string
Interface string
Debug bool
}
func initFlags() {
flag.StringVar(&Flags.Path, "config", "Config.yaml", "config path")
flag.StringVar(&Flags.Interface, "interface", "", "specify the eth name")
flag.BoolVar(&Flags.Debug, "debug", false, "enable debug mode")
flag.Parse()
}

View File

@@ -11,6 +11,9 @@ import (
)
func initLog() {
if Flags.Debug {
Config.Settings.Log.DebugLevel = true
}
if Config.Settings.Log.DebugLevel {
log.SetLevel(log.DebugLevel)
}