th7/db/logging.go

28 lines
467 B
Go

package db
import (
"log"
"th7/ports"
"time"
)
func startLoggingProcess(db ports.DBPort, core ports.CorePort, dur time.Duration) {
log.Printf("[DB] logging frequency=%v\n", dur)
// wait 15 seconds to not log start up values that can be noisy
time.Sleep(15 * time.Second)
for {
val := core.GetChannels()
err := db.Save(val)
if err != nil {
log.Printf("[DB] Error encountered when attempting to save logs: %v\n", err)
}
time.Sleep(dur)
}
}