From fa29b09aab3e07951af6beaba5aa573b03c4347b Mon Sep 17 00:00:00 2001 From: "Matthew R. Kasun" Date: Thu, 21 Apr 2022 16:18:27 -0400 Subject: [PATCH] permit setting of verbosity from config Signed-off-by: Matthew R. Kasun --- config/config.go | 2 +- servercfg/serverconf.go | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/config/config.go b/config/config.go index 3872ef82..cd0344e6 100644 --- a/config/config.go +++ b/config/config.go @@ -52,7 +52,7 @@ type ServerConfig struct { Platform string `yaml:"platform"` Database string `yaml:"database"` DefaultNodeLimit int32 `yaml:"defaultnodelimit"` - Verbosity int32 `yaml:"verbosity"` + Verbosity int `yaml:"verbosity"` ServerCheckinInterval int64 `yaml:"servercheckininterval"` AuthProvider string `yaml:"authprovider"` ClientID string `yaml:"clientid"` diff --git a/servercfg/serverconf.go b/servercfg/serverconf.go index 1f25034a..93144c4b 100644 --- a/servercfg/serverconf.go +++ b/servercfg/serverconf.go @@ -90,6 +90,7 @@ func GetServerConfig() config.ServerConfig { services := strings.Join(GetPortForwardServiceList(), ",") cfg.PortForwardServices = services cfg.Server = GetServer() + cfg.Verbosity = GetVerbosity() return cfg } @@ -352,6 +353,21 @@ func GetServer() string { return server } +func GetVerbosity() int { + var verbosity = 0 + var err error + if os.Getenv("VERBOSITY") != "" { + verbosity, err = strconv.Atoi(os.Getenv("VERBOSITY")) + if err != nil { + verbosity = 0 + } + } else if config.Config.Server.Verbosity != 0 { + verbosity = config.Config.Server.Verbosity + } + logger.Verbosity = int(verbosity) + return verbosity +} + // IsDNSMode - should it run with DNS func IsDNSMode() bool { isdns := true