Adjust log timing

This commit is contained in:
Garth Vander Houwen 2024-06-06 08:19:11 -07:00
parent d5884988b1
commit d12c755eb9
2 changed files with 3 additions and 7 deletions

View file

@ -25,10 +25,10 @@ extension Logger {
static let statistics = Logger(subsystem: subsystem, category: "📈 Stats")
/// Fetch from the logstore
static public func fetch(since date: Date, predicateFormat: String) async throws -> [OSLogEntryLog] {
static public func fetch(predicateFormat: String) async throws -> [OSLogEntryLog] {
let store = try OSLogStore(scope: .currentProcessIdentifier)
let position = store.position(date: date)
let position = store.position(timeIntervalSinceLatestBoot: 0)
let predicate = NSPredicate(format: predicateFormat)
let entries = try store.getEntries(at: position, matching: predicate)

View file

@ -98,17 +98,13 @@ extension AppLog {
@MainActor
private func fetchLogs() async -> [OSLogEntryLog] {
let calendar = Calendar.current
guard let dayAgo = calendar.date(byAdding: .day, value: -1, to: Date.now) else {
return []
}
do {
let predicate = AppLog.template.withSubstitutionVariables(
[
"PREFIX": "gvh.MeshtasticClient",
"SYSTEM": ["com.apple.coredata"]
])
let logs = try await Logger.fetch(since: dayAgo, predicateFormat: predicate.predicateFormat)
let logs = try await Logger.fetch(predicateFormat: predicate.predicateFormat)
return logs
} catch {
return []