From 9ca99c7ed30afd0666dcff291795ef0087b3b8cf Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Thu, 6 Jun 2024 22:51:16 -0700 Subject: [PATCH] Add admin messages category Remove admin message log --- Meshtastic/Extensions/Logger.swift | 6 ++++++ Meshtastic/Helpers/BLEManager.swift | 4 ++-- Meshtastic/Views/Settings/AppLog.swift | 4 ++-- Meshtastic/Views/Settings/Settings.swift | 11 ----------- 4 files changed, 10 insertions(+), 15 deletions(-) diff --git a/Meshtastic/Extensions/Logger.swift b/Meshtastic/Extensions/Logger.swift index 930d47ef..c932d4df 100644 --- a/Meshtastic/Extensions/Logger.swift +++ b/Meshtastic/Extensions/Logger.swift @@ -17,6 +17,9 @@ extension Logger { /// All logs related to the mesh static let mesh = Logger(subsystem: subsystem, category: "πŸ•ΈοΈ Mesh") + + /// All admin messages + static let admin = Logger(subsystem: subsystem, category: "πŸ› Admin") /// All logs related to services such as network calls, location, etc. static let services = Logger(subsystem: subsystem, category: "🍏 Services") @@ -29,6 +32,9 @@ extension Logger { let store = try OSLogStore(scope: .currentProcessIdentifier) let position = store.position(timeIntervalSinceLatestBoot: 0) + let calendar = Calendar.current + //let dayAgo = calendar.date(byAdding: .day, value: -1, to: Date.now) + //let position = store.position(date: dayAgo!) let predicate = NSPredicate(format: predicateFormat) let entries = try store.getEntries(at: position, matching: predicate) diff --git a/Meshtastic/Helpers/BLEManager.swift b/Meshtastic/Helpers/BLEManager.swift index fb2c5f29..aad44104 100644 --- a/Meshtastic/Helpers/BLEManager.swift +++ b/Meshtastic/Helpers/BLEManager.swift @@ -2824,12 +2824,12 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate do { connectedPeripheral.peripheral.writeValue(binaryData, for: TORADIO_characteristic, type: .withResponse) try context!.save() - Logger.mesh.debug("\(adminDescription)") + Logger.admin.debug("\(adminDescription)") return true } catch { context!.rollback() let nsError = error as NSError - Logger.data.error("Error inserting new core data MessageEntity: \(nsError)") + Logger.admin.error("Error inserting new core data admin MessageEntity: \(nsError)") } } return false diff --git a/Meshtastic/Views/Settings/AppLog.swift b/Meshtastic/Views/Settings/AppLog.swift index ffb83514..4feb0865 100644 --- a/Meshtastic/Views/Settings/AppLog.swift +++ b/Meshtastic/Views/Settings/AppLog.swift @@ -12,7 +12,7 @@ import OSLog struct AppLog: View { @State private var logs: [OSLogEntryLog] = [] - @State private var sortOrder = [KeyPathComparator(\OSLogEntryLog.date)] + @State private var sortOrder = [KeyPathComparator(\OSLogEntryLog.date, order: .forward)] @State private var selection: OSLogEntry.ID? @State private var selectedLog: OSLogEntryLog? @State private var presentingErrorDetails: Bool = false @@ -53,7 +53,7 @@ struct AppLog: View { .width(ideal: 200, max: .infinity) } - .searchable(text: $searchTerm, prompt: "Search") + .searchable(text: $searchTerm, placement: .navigationBarDrawer, prompt: "Search") .disabled(selection != nil) .overlay { if logs.isEmpty { diff --git a/Meshtastic/Views/Settings/Settings.swift b/Meshtastic/Views/Settings/Settings.swift index 45a14230..690ebdaa 100644 --- a/Meshtastic/Views/Settings/Settings.swift +++ b/Meshtastic/Views/Settings/Settings.swift @@ -413,17 +413,6 @@ struct Settings: View { } } .tag(SettingsSidebar.meshLog) - NavigationLink { - let connectedNode = nodes.first(where: { $0.num == preferredNodeNum }) - AdminMessageList(user: connectedNode?.user) - } label: { - Label { - Text("admin.log") - } icon: { - Image(systemName: "building.columns") - } - } - .tag(SettingsSidebar.adminMessageLog) if #available (iOS 17.4, *) { NavigationLink { AppLog()