Hello Apple,
I might be wrong but it seems like getEntries(with:at:matching:)
is missing from iOS? Else please tell me how I should the get log entries on iOS 😃
Please see the documentation at https://developer.apple.com/documentation/oslog/oslogstore/3204125-getentries
Regards,
Jens
This seems to be in fact working in Beta 1 in the simulator and on device: see the sample below.
Despite being marked as NS_REFINED_FOR_SWIFT
you need to call this as described in https://developer.apple.com/documentation/swift/objective-c_and_c_code_customization/improving_objective-c_api_declarations_for_swift
@main
struct LogReaderApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
}
init() {
do {
os_log("Test message! \(UInt(42), format: .hex)")
let store = try OSLogStore.init(scope: .currentProcessIdentifier)
let position = store.position(date: Date().addingTimeInterval(-3600))
let enumerator = try store.__entriesEnumerator(options: [.reverse], position: position, predicate: nil)
enumerator.forEach { element in
var message = element as? OSLogEntry
dump(message.debugDescription)
dump(message?.composedMessage)
}
} catch {
dump(error)
}
}
}