Add operation column that says what the app was actually doing.

This commit is contained in:
Brent Simmons committed 2026-03-12 20:19:49 -07:00
1 parent 21907eef6e
commit 3587b5eba0
6 files changed
+39 -25

No files matched your search

@@ -14,7 +14,7 @@ public actor ErrorLogDatabase {
private let database: FMDatabase
private static let tableCreationStatements = "CREATE TABLE if not EXISTS errors (id INTEGER PRIMARY KEY AUTOINCREMENT, date REAL NOT NULL, sourceName TEXT NOT NULL, sourceID INTEGER NOT NULL, errorMessage TEXT NOT NULL);"
private static let tableCreationStatements = "CREATE TABLE if not EXISTS errors (id INTEGER PRIMARY KEY AUTOINCREMENT, date REAL NOT NULL, sourceName TEXT NOT NULL, sourceID INTEGER NOT NULL, operation TEXT NOT NULL, errorMessage TEXT NOT NULL);"
private static let pruneLimit = 200
@@ -31,8 +31,8 @@ public actor ErrorLogDatabase {
}
}
public func addEntry(sourceName: String, sourceID: Int, errorMessage: String) {
ErrorLogTable.insertEntry(sourceName: sourceName, sourceID: sourceID, errorMessage: errorMessage, database: database)
public func addEntry(sourceName: String, sourceID: Int, operation: String, errorMessage: String) {
ErrorLogTable.insertEntry(sourceName: sourceName, sourceID: sourceID, operation: operation, errorMessage: errorMessage, database: database)
}
public func allEntries() -> [ErrorLogEntry] {
@@ -47,8 +47,9 @@ public actor ErrorLogDatabase {
let sourceID = notification.userInfo?[ErrorLogUserInfoKey.sourceID] as? Int else {
return
}
let operation = notification.userInfo?[ErrorLogUserInfoKey.operation] as? String ?? ""
Task {
await addEntry(sourceName: sourceName, sourceID: sourceID, errorMessage: errorMessage)
await addEntry(sourceName: sourceName, sourceID: sourceID, operation: operation, errorMessage: errorMessage)
}
}
}