Include fractional seconds in log timestamps

This commit is contained in:
Shadowfacts 2023-05-11 20:46:25 -04:00
parent fc391cc18c
commit 4dbc4ebeb2
1 changed files with 2 additions and 1 deletions

View File

@ -22,12 +22,13 @@ struct Logging {
let entries = try store.getEntries() let entries = try store.getEntries()
var data = Data() var data = Data()
let subsystem = Bundle.main.bundleIdentifier! let subsystem = Bundle.main.bundleIdentifier!
let format = Date.ISO8601FormatStyle(includingFractionalSeconds: true)
for entry in entries { for entry in entries {
guard let entry = entry as? OSLogEntryLog, guard let entry = entry as? OSLogEntryLog,
entry.subsystem == subsystem else { entry.subsystem == subsystem else {
continue continue
} }
data.append(contentsOf: entry.date.formatted(.iso8601).utf8) data.append(contentsOf: entry.date.formatted(format).utf8)
data.append(32) // ' ' data.append(32) // ' '
data.append(91) // '[' data.append(91) // '['
data.append(contentsOf: entry.category.utf8) data.append(contentsOf: entry.category.utf8)