From 4a234d50e2cf4661cc8368c8d250f15935ee5883 Mon Sep 17 00:00:00 2001 From: Senis Date: Fri, 29 Dec 2023 12:25:33 +0800 Subject: [PATCH] Add debug level logging option This update introduces the ability to enable logging from the caller when the log level is set to "debug". This additional logging feature will provide more specificity and context for debugging tasks, aiding in quicker issue resolution. --- cmd/root.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cmd/root.go b/cmd/root.go index 51c8cee..3fb87c4 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -75,6 +75,11 @@ func run() error { if err := config.Unmarshal(panelConfig); err != nil { return fmt.Errorf("Parse config file %v failed: %s \n", cfgFile, err) } + + if panelConfig.LogConfig.Level == "debug" { + log.SetReportCaller(true) + } + p := panel.New(panelConfig) lastTime := time.Now() config.OnConfigChange(func(e fsnotify.Event) { @@ -88,10 +93,16 @@ func run() error { if err := config.Unmarshal(panelConfig); err != nil { log.Panicf("Parse config file %v failed: %s \n", cfgFile, err) } + + if panelConfig.LogConfig.Level == "debug" { + log.SetReportCaller(true) + } + p.Start() lastTime = time.Now() } }) + p.Start() defer p.Close()