feat: persist logs to DB, load on startup

This commit is contained in:
2026-05-16 15:25:08 -04:00
parent 4d375cf874
commit ed082e4080
7 changed files with 59 additions and 0 deletions
+14
View File
@@ -68,6 +68,20 @@ func (e *Engine) AddLog(msg string) {
if len(e.logStore) > 100 {
e.logStore = e.logStore[:100]
}
go func() { _ = e.db.SaveLog(entry) }()
}
func (e *Engine) InitLogs() {
logs, err := e.db.LoadLogs(100)
if err != nil {
return
}
if len(logs) == 0 {
return
}
e.logMu.Lock()
defer e.logMu.Unlock()
e.logStore = logs
}
func (e *Engine) GetLogs() []string {