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.
This commit is contained in:
Senis 2023-12-29 12:25:33 +08:00
parent 115d7bad6f
commit 4a234d50e2
No known key found for this signature in database

View File

@ -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()