improve: 支持通过 flag 开启 debug 模式
This commit is contained in:
@@ -9,10 +9,12 @@ var Flags struct {
|
|||||||
Path string
|
Path string
|
||||||
|
|
||||||
Interface string
|
Interface string
|
||||||
|
Debug bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func initFlags() {
|
func initFlags() {
|
||||||
flag.StringVar(&Flags.Path, "config", "Config.yaml", "config path")
|
flag.StringVar(&Flags.Path, "config", "Config.yaml", "config path")
|
||||||
flag.StringVar(&Flags.Interface, "interface", "", "specify the eth name")
|
flag.StringVar(&Flags.Interface, "interface", "", "specify the eth name")
|
||||||
|
flag.BoolVar(&Flags.Debug, "debug", false, "enable debug mode")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func initLog() {
|
func initLog() {
|
||||||
|
if Flags.Debug {
|
||||||
|
Config.Settings.Log.DebugLevel = true
|
||||||
|
}
|
||||||
if Config.Settings.Log.DebugLevel {
|
if Config.Settings.Log.DebugLevel {
|
||||||
log.SetLevel(log.DebugLevel)
|
log.SetLevel(log.DebugLevel)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user