Limit the log entries to a max number
This commit is contained in:
parent
46d904acc6
commit
8279a08a37
1 changed files with 9 additions and 0 deletions
|
@ -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")
|
||||
|
|
Loading…
Add table
Reference in a new issue