From 46ae0b382218dc9d5889cd811974cd766f537cbd Mon Sep 17 00:00:00 2001 From: bui Date: Thu, 26 Oct 2023 12:03:57 +0200 Subject: [PATCH] properly set default log level --- pkg/waf/waap.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/waf/waap.go b/pkg/waf/waap.go index 4982c5763..997f1799b 100644 --- a/pkg/waf/waap.go +++ b/pkg/waf/waap.go @@ -81,7 +81,7 @@ type WaapConfig struct { PreEval []Hook `yaml:"pre_eval"` OnMatch []Hook `yaml:"on_match"` VariablesTracking []string `yaml:"variables_tracking"` - LogLevel log.Level `yaml:"log_level"` + LogLevel *log.Level `yaml:"log_level"` Logger *log.Entry `yaml:"-"` } @@ -110,8 +110,12 @@ func (wc *WaapConfig) Load(file string) error { if wc.Name == "" { return fmt.Errorf("name cannot be empty") } + if wc.LogLevel == nil { + lvl := log.InfoLevel + wc.LogLevel = &lvl + } wc.Logger = wc.Logger.WithField("name", wc.Name) - wc.Logger.Logger.SetLevel(wc.LogLevel) + wc.Logger.Logger.SetLevel(*wc.LogLevel) if wc.DefaultRemediation == "" { return fmt.Errorf("default_remediation cannot be empty") }