-
-
Notifications
You must be signed in to change notification settings - Fork 355
Open
Description
We use this code to export a log file:
let documentsDirectory = FileManager.default.temporaryDirectory
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd-HHmmss"
let dateString = dateFormatter.string(from: Date())
let fiveMinutesAgo = Date().addingTimeInterval(-5 * 60) // 5 minutes in seconds
let fiveMinutesAgoPredicate = NSPredicate(format: "createdAt >= %@", fiveMinutesAgo as NSDate)
let logFileURL = documentsDirectory.appendingPathComponent("logs-\(dateString).txt")
try await LoggerStore.shared.export(
to: logFileURL,
options: .init(predicate: fiveMinutesAgoPredicate, sessions: [LoggerStore.shared.session.id])
)
This work most of the time, but sometimes throws an error:
Error Domain=NSCocoaErrorDomain Code=134030 "An error occurred while saving." UserInfo={object=<Pulse.LoggerBlobHandleEntity: 0x60000246bbb0> (entity: LoggerBlobHandleEntity; id: 0xa438a086287c5a46 <x-coredata://2F30A1B8-A2DA-47E4-8384-E9CBD87EC391/LoggerBlobHandleEntity/p900>; data: <fault>), NSUnderlyingException=Save failed during during migratePersistentStore:toURL:options:withType:error:, object added to store during fetch.}
thanks!
Metadata
Metadata
Assignees
Labels
No labels