From 8279a08a376edc93e53bcff552aede6a2398ff28 Mon Sep 17 00:00:00 2001 From: Marc Di Luzio Date: Thu, 23 Jul 2020 16:47:39 +0100 Subject: [PATCH] Limit the log entries to a max number --- pkg/rove/rover.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkg/rove/rover.go b/pkg/rove/rover.go index fb13ddc..ce0edcd 100644 --- a/pkg/rove/rover.go +++ b/pkg/rove/rover.go @@ -13,6 +13,10 @@ import ( "github.com/mdiluz/rove/proto/roveapi" ) +const ( + maxLogEntries = 16 +) + // RoverLogEntry describes a single log entry for the rover type RoverLogEntry struct { // Time is the timestamp of the entry @@ -89,6 +93,11 @@ func (r *Rover) AddLogEntryf(format string, args ...interface{}) { Text: text, }, ) + + // Limit the number of logs + if len(r.Logs) > maxLogEntries { + r.Logs = r.Logs[len(r.Logs)-maxLogEntries:] + } } var wordsFile = os.Getenv("WORDS_FILE")