CrashReporter icon indicating copy to clipboard operation
CrashReporter copied to clipboard

Integrate PLCrashReporter's text formatter for new crash logs

Open DivineDominion opened this issue 8 months ago • 0 comments

Modern macOS formats crash reports differently than it used to. PLCrashReporter comes with a formatter that could help provide us with readable crash logs.

The rest of the PLCrashReporter source is less relevant, but the formatter types can be cherry picked. For inspiration, see NetNewsWire: https://github.com/Ranchero-Software/NetNewsWire/commit/3022f78434bf7f8e57f879edf6de4e6431357a2e

guard crashReporter.hasPendingCrashReport(),
    let crashData = crashReporter.loadPendingCrashReportData(),
    let crashReport = try? PLCrashReport(data: crashData),
    let crashLogText = PLCrashReportTextFormatter.stringValue(for: crashReport, with: PLCrashReportTextFormatiOS) 
else { return }

This would replace the .crash file lookup part and extraction of the string contents:

  1. The call to send(...) will be affected, and
  2. CrashInfo would wrap the PLCrashReport and expose its content string via PLCrashReportTextFormatter

DivineDominion avatar Oct 26 '23 06:10 DivineDominion