Hello.
I'm developing a tightly coupled watchOS/iOS app. The customer needs to be able to write logs to text files, from both apps, in a hassle-free way.
So I want to retrieve entries using OSLogStore, which works just fine on iOS:
let store = try OSLogStore(scope: .currentProcessIdentifier)
let pos = store.position(timeIntervalSinceEnd: -seconds)
let entries = try store
.getEntries(with: [], at: pos, matching: nil)
.compactMap { $0 as? OSLogEntryLog }
.filter { $0.subsystem == Bundle.main.bundleIdentifier! }
.map { "[\($0.date.formatted())] [\($0.category)] \($0.composedMessage)" }
.joined(separator: "\n")
I've tried the same code on watchOS, with and without the filtering, but it always returns 0 entries.
I can't find anything relating to this behavior in the documentation. So... does it just not work?
Using a Watch SE 44mm and running watchOS 8.5
Thanks!