From c8709d67dbf023cd302940fea8cfc4d51864672d Mon Sep 17 00:00:00 2001 From: Fred Boniface Date: Sun, 14 Apr 2024 20:07:56 +0100 Subject: [PATCH] Log tidying --- background/ticker.go | 7 +++++-- cif/check.go | 2 +- main.go | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/background/ticker.go b/background/ticker.go index 0427d4a..a2af87c 100644 --- a/background/ticker.go +++ b/background/ticker.go @@ -2,6 +2,7 @@ package background import ( "math" + "os" "runtime" "time" @@ -18,8 +19,8 @@ const frequency = 2 * time.Hour // Figure out a sensible frequency! func InitTicker(cfg *helpers.Configuration, stop <-chan struct{}) { go runTicker(cfg, stop) - // Run goroutine logging ticker if runtime set to debug - if helpers.Runtime == "debug" { + // Run goroutine logging ticker if env "perflog" is set to "on" + if os.Getenv("perflog") == "on" { go goroutineTicker(stop) } } @@ -33,8 +34,10 @@ func runTicker(cfg *helpers.Configuration, stop <-chan struct{}) { for { select { case <-stop: + log.Debug("Stopping background task ticker") return case <-ticker.C: + log.Debug("Running background tasks") go cif.CheckCif(cfg) go corpus.CheckCorpus(cfg) } diff --git a/cif/check.go b/cif/check.go index f3b80ab..d832cb4 100644 --- a/cif/check.go +++ b/cif/check.go @@ -18,7 +18,7 @@ func CheckCif(cfg *helpers.Configuration) { return } - log.Info("Checking age of CIF Data") + log.Debug("Checking age of CIF Data") // Load and read metadata from database metadata, err := dbAccess.GetCifMetadata() diff --git a/main.go b/main.go index 61acd61..bbb501c 100644 --- a/main.go +++ b/main.go @@ -21,7 +21,7 @@ import ( func init() { printStartupBanner() - fmt.Println("Version", helpers.Version, "\n\n") + fmt.Printf("Version %s \n\n", helpers.Version) } func main() {