summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorRobby Zambito <contact@robbyzambito.me>2025-08-08 13:12:30 -0400
committerRobby Zambito <contact@robbyzambito.me>2025-08-08 13:12:33 -0400
commit9671b4abf936f59b9d04f9d26b301e65fa78753d (patch)
tree330cbfb7450fd96bf9f9b9f5e58d110ef083c75f /internal
parenta6105d2dda398531ee66f996fa6d69fe934e6f5c (diff)
Log incidents
Diffstat (limited to 'internal')
-rw-r--r--internal/api/handlers.go10
1 files changed, 7 insertions, 3 deletions
diff --git a/internal/api/handlers.go b/internal/api/handlers.go
index 5a31fa3..2cc2188 100644
--- a/internal/api/handlers.go
+++ b/internal/api/handlers.go
@@ -90,7 +90,7 @@ func CreateLoginHandler(logs *[LogLength]string, n *int, toLogParser chan string
var status statusData
-func init() {
+func InitializeAPI(logs *[LogLength]string, n *int, toLogParser chan string) {
// Backfill status
// status.overallStatus = overallStatus{
@@ -191,7 +191,7 @@ func init() {
runChance(0.5, func() {
serviceStatus = StatusDegraded
})
- status.incidents = append(status.incidents, incident{
+ newIncident := incident{
Id: fmt.Sprintf("%d", incidentId),
Title: allIncidentTitles[i],
Description: allIncidentDescriptions[i],
@@ -199,8 +199,12 @@ func init() {
Severity: severity,
StartTime: time.Now().UTC(),
AffectedServices: []string{},
- })
+ }
+ status.incidents = append(status.incidents, newIncident)
incidentId++
+
+ jsonData, _ := json.Marshal(newIncident)
+ addRotLog(logs, n, toLogParser, fmt.Sprintf(`{"incidentEvent": %s}`, string(jsonData)))
})
status.overallStatus.ActiveIncidents = len(status.incidents)
}