mirror of
https://github.com/Aminark/legado-ios.git
synced 2026-10-24 12:51:22 +08:00
feat: open-source 小浣熊阅读 for iOS
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import Foundation
|
||||
import MetricKit
|
||||
|
||||
final class AppDiagnostics: NSObject, MXMetricManagerSubscriber, @unchecked Sendable {
|
||||
static let shared = AppDiagnostics()
|
||||
|
||||
func start() {
|
||||
MXMetricManager.shared.add(self)
|
||||
DiagnosticLog.shared.record(category: "应用", message: "启动 \(Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String ?? "")")
|
||||
}
|
||||
|
||||
func didReceive(_ payloads: [MXDiagnosticPayload]) {
|
||||
for payload in payloads {
|
||||
for crash in payload.crashDiagnostics ?? [] {
|
||||
DiagnosticLog.shared.record(.error, category: "系统诊断", message: "崩溃诊断:\(String(decoding: crash.jsonRepresentation(), as: UTF8.self))")
|
||||
}
|
||||
for hang in payload.hangDiagnostics ?? [] {
|
||||
DiagnosticLog.shared.record(.warning, category: "系统诊断", message: "卡顿诊断:\(String(decoding: hang.jsonRepresentation(), as: UTF8.self))")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user