Files
BanForge/internal/storage/writer.go
2026-01-13 21:03:10 +03:00

23 lines
458 B
Go

package storage
import (
"time"
)
func Write(db *DB, resultCh <-chan *LogEntry) {
for result := range resultCh {
_, err := db.db.Exec(
"INSERT INTO requests (service, ip, path, method, status, created_at) VALUES (?, ?, ?, ?, ?, ?)",
result.Service,
result.IP,
result.Path,
result.Method,
result.Status,
time.Now().Format(time.RFC3339),
)
if err != nil {
db.logger.Error("Failed to write to database", "error", err)
}
}
}