2022-11-16 00:07:01 +00:00
|
|
|
package db
|
|
|
|
|
|
|
|
import (
|
2023-11-25 10:37:02 +00:00
|
|
|
"log"
|
2022-11-16 00:07:01 +00:00
|
|
|
"th7/ports"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
func startLoggingProcess(db ports.DBPort, core ports.CorePort, dur time.Duration) {
|
|
|
|
|
2023-11-23 20:46:54 +00:00
|
|
|
// wait 15 seconds to not log start up values that can be noisy
|
|
|
|
time.Sleep(15 * time.Second)
|
2022-11-16 00:07:01 +00:00
|
|
|
|
2022-11-16 20:07:38 +00:00
|
|
|
for {
|
2022-11-16 00:07:01 +00:00
|
|
|
|
2022-11-16 20:07:38 +00:00
|
|
|
val := core.GetChannels()
|
2022-11-16 00:07:01 +00:00
|
|
|
|
2022-11-16 20:07:38 +00:00
|
|
|
err := db.Save(val)
|
2022-11-16 00:07:01 +00:00
|
|
|
if err != nil {
|
2023-11-25 10:37:02 +00:00
|
|
|
log.Printf("[DB] Error encountered when attempting to save logs: %v\n", err)
|
2022-11-16 00:07:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
time.Sleep(dur)
|
|
|
|
}
|
|
|
|
}
|