From e895e6fe1dfb9404e775462824924ef147a189b9 Mon Sep 17 00:00:00 2001 From: Mmx233 Date: Thu, 1 Jun 2023 18:36:39 +0800 Subject: [PATCH] =?UTF-8?q?improve:=20=E6=94=AF=E6=8C=81=E9=80=9A=E8=BF=87?= =?UTF-8?q?=20flag=20=E5=BC=80=E5=90=AF=20debug=20=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/global/flags.go | 2 ++ internal/global/log.go | 3 +++ 2 files changed, 5 insertions(+) diff --git a/internal/global/flags.go b/internal/global/flags.go index a5558db..1f97988 100644 --- a/internal/global/flags.go +++ b/internal/global/flags.go @@ -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() } diff --git a/internal/global/log.go b/internal/global/log.go index 5415340..26be3cf 100644 --- a/internal/global/log.go +++ b/internal/global/log.go @@ -11,6 +11,9 @@ import ( ) func initLog() { + if Flags.Debug { + Config.Settings.Log.DebugLevel = true + } if Config.Settings.Log.DebugLevel { log.SetLevel(log.DebugLevel) }