feat(logging): Allow configuring logging verbosity level (#872)

* introduces TwiN/logr library

* use new features of logr library

* minor tweaks and formatting

* Apply suggestions from code review

---------

Co-authored-by: TwiN <twin@linux.com>
This commit is contained in:
Gary Hodgson
2024-11-14 01:02:53 +01:00
committed by GitHub
parent 92bb42d444
commit 8060a77b1f
6 changed files with 32 additions and 20 deletions

View File

@ -12,6 +12,7 @@ import (
"github.com/TwiN/gatus/v5/controller"
"github.com/TwiN/gatus/v5/storage/store"
"github.com/TwiN/gatus/v5/watchdog"
"github.com/TwiN/logr"
)
func main() {
@ -23,6 +24,7 @@ func main() {
if err != nil {
panic(err)
}
configureLogging(cfg)
initializeStorage(cfg)
start(cfg)
// Wait for termination signal
@ -57,6 +59,11 @@ func save() {
}
}
func configureLogging(cfg *config.Config) {
logr.SetThreshold(cfg.LogLevel)
logr.Infof("[main.configureLogging] Log Level is %s", logr.GetThreshold())
}
func loadConfiguration() (*config.Config, error) {
configPath := os.Getenv("GATUS_CONFIG_PATH")
// Backwards compatibility