From 16fa1c53541741a518d06f08a94681e1cc6779fb Mon Sep 17 00:00:00 2001 From: Fred Boniface Date: Sat, 13 Apr 2024 21:45:05 +0100 Subject: [PATCH] Adjust how performance logging is managed --- background/ticker.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/background/ticker.go b/background/ticker.go index 04dcac5..88c4c94 100644 --- a/background/ticker.go +++ b/background/ticker.go @@ -1,7 +1,7 @@ package background import ( - "fmt" + "math" "runtime" "time" @@ -9,6 +9,7 @@ import ( "git.fjla.uk/owlboard/timetable-mgr/corpus" "git.fjla.uk/owlboard/timetable-mgr/helpers" "git.fjla.uk/owlboard/timetable-mgr/log" + "go.uber.org/zap" ) const frequency = 2 * time.Hour // Figure out a sensible frequency! @@ -60,7 +61,8 @@ func debugLog() { runtime.ReadMemStats(&memStats) goroutines := runtime.NumGoroutine() + heapMem := float64(memStats.HeapAlloc) / (1024 * 1024) + heapMemRound := math.Round(heapMem*100) / 100 - fmt.Printf("\nNumber of goroutines: %d\n", goroutines) - fmt.Printf("Heap Allocated memory: %2f MB\n\n", float64(memStats.HeapAlloc)/(1024*1024)) + log.Msg.Debug("Performance", zap.Int("goroutine-count", goroutines), zap.Float64("heap-mem (MB)", heapMemRound)) }