From 9f1b3975f8a59b51975b1c509e72c4ec2e4f891c Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Fri, 28 Jun 2024 19:30:12 -0700 Subject: [PATCH] Use indigo for debug color, clean up filters --- Meshtastic.xcodeproj/project.pbxproj | 4 +++ Meshtastic/Extensions/Logger.swift | 26 -------------- Meshtastic/Extensions/OSLogEntryLog.swift | 35 +++++++++++++++++++ .../Helpers/Map/OfflineTileManager.swift | 2 +- Meshtastic/Persistence/UpdateCoreData.swift | 2 +- .../Views/Settings/Logs/AppLogFilter.swift | 2 +- 6 files changed, 42 insertions(+), 29 deletions(-) create mode 100644 Meshtastic/Extensions/OSLogEntryLog.swift diff --git a/Meshtastic.xcodeproj/project.pbxproj b/Meshtastic.xcodeproj/project.pbxproj index 6e724c46..3ff8481e 100644 --- a/Meshtastic.xcodeproj/project.pbxproj +++ b/Meshtastic.xcodeproj/project.pbxproj @@ -152,6 +152,7 @@ DDD5BB092C285DDC007E03CA /* AppLog.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDD5BB082C285DDC007E03CA /* AppLog.swift */; }; DDD5BB0B2C285E45007E03CA /* LogDetail.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDD5BB0A2C285E45007E03CA /* LogDetail.swift */; }; DDD5BB102C285FB3007E03CA /* AppLogFilter.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDD5BB0F2C285FB3007E03CA /* AppLogFilter.swift */; }; + DDD5BB182C2F9C36007E03CA /* OSLogEntryLog.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDD5BB172C2F9C36007E03CA /* OSLogEntryLog.swift */; }; DDD6EEAF29BC024700383354 /* Firmware.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDD6EEAE29BC024700383354 /* Firmware.swift */; }; DDD94A502845C8F5004A87A0 /* DateTimeText.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDD94A4F2845C8F5004A87A0 /* DateTimeText.swift */; }; DDD9E4E4284B208E003777C5 /* UserEntityExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = DDD9E4E3284B208E003777C5 /* UserEntityExtension.swift */; }; @@ -397,6 +398,7 @@ DDD5BB0F2C285FB3007E03CA /* AppLogFilter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppLogFilter.swift; sourceTree = ""; }; DDD5BB142C28680D007E03CA /* MeshtasticDataModelV 38.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "MeshtasticDataModelV 38.xcdatamodel"; sourceTree = ""; }; DDD5BB152C28B1E4007E03CA /* AppData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppData.swift; sourceTree = ""; }; + DDD5BB172C2F9C36007E03CA /* OSLogEntryLog.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OSLogEntryLog.swift; sourceTree = ""; }; DDD6EEAE29BC024700383354 /* Firmware.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Firmware.swift; sourceTree = ""; }; DDD94A4F2845C8F5004A87A0 /* DateTimeText.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DateTimeText.swift; sourceTree = ""; }; DDD9E4E3284B208E003777C5 /* UserEntityExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserEntityExtension.swift; sourceTree = ""; }; @@ -903,6 +905,7 @@ DDFFA7462B3A7F3C004730DB /* Bundle.swift */, DDF45C362BC46A5A005ED5F2 /* TimeZone.swift */, DDD5BB0C2C285F00007E03CA /* Logger.swift */, + DDD5BB172C2F9C36007E03CA /* OSLogEntryLog.swift */, ); path = Extensions; sourceTree = ""; @@ -1095,6 +1098,7 @@ D93069082B81DF040066FBC8 /* SaveConfigButton.swift in Sources */, DD5E523F298F5A9E00D21B61 /* AirQualityIndex.swift in Sources */, DD964FBF296E76EF007C176F /* WaypointFormMapKit.swift in Sources */, + DDD5BB182C2F9C36007E03CA /* OSLogEntryLog.swift in Sources */, DD3501892852FC3B000FC853 /* Settings.swift in Sources */, DDDC22382BA92344002C44F1 /* MeshMapContent.swift in Sources */, DDDB443629F6287000EE2349 /* MapButtons.swift in Sources */, diff --git a/Meshtastic/Extensions/Logger.swift b/Meshtastic/Extensions/Logger.swift index 95817ea4..402c0c1b 100644 --- a/Meshtastic/Extensions/Logger.swift +++ b/Meshtastic/Extensions/Logger.swift @@ -6,7 +6,6 @@ // import OSLog -import SwiftUI extension Logger { @@ -59,28 +58,3 @@ extension Logger { return logs } } - -extension OSLogEntryLog.Level { - var description: String { - switch self { - case .undefined: "undefined" - case .debug: "🪲 Debug" - case .info: "ℹ️ Info" - case .notice: "⚠️ Notice" - case .error: "🚨 Error" - case .fault: "💥 Fault" - @unknown default: "default" - } - } - var color: Color { - switch self { - case .undefined: .green - case .debug: .blue - case .info: .green - case .notice: .orange - case .error: .red - case .fault: .red - @unknown default: .green - } - } -} diff --git a/Meshtastic/Extensions/OSLogEntryLog.swift b/Meshtastic/Extensions/OSLogEntryLog.swift new file mode 100644 index 00000000..9d42b70c --- /dev/null +++ b/Meshtastic/Extensions/OSLogEntryLog.swift @@ -0,0 +1,35 @@ +// +// OSLogEntryLog.swift +// Meshtastic +// +// Copyright(c) Garth Vander Houwen 6/28/24. +// + +import OSLog +import SwiftUI + +/// Extensions to allow rendering of the emoji string and log leve coloring in the grid of OSLogEntryLog items +extension OSLogEntryLog.Level { + var description: String { + switch self { + case .undefined: "undefined" + case .debug: "🪲 Debug" + case .info: "ℹ️ Info" + case .notice: "⚠️ Notice" + case .error: "🚨 Error" + case .fault: "💥 Fault" + @unknown default: "default" + } + } + var color: Color { + switch self { + case .undefined: .green + case .debug: .indigo + case .info: .green + case .notice: .orange + case .error: .red + case .fault: .red + @unknown default: .green + } + } +} diff --git a/Meshtastic/Helpers/Map/OfflineTileManager.swift b/Meshtastic/Helpers/Map/OfflineTileManager.swift index dceb09cc..66afa93c 100644 --- a/Meshtastic/Helpers/Map/OfflineTileManager.swift +++ b/Meshtastic/Helpers/Map/OfflineTileManager.swift @@ -21,7 +21,7 @@ class OfflineTileManager: ObservableObject { } init() { - Logger.services.debug("Documents Directory = \(self.documentsDirectory.absoluteString, privacy: .public)") + Logger.services.info("🗂️ Documents Directory = \(self.documentsDirectory.absoluteString, privacy: .public)") createDirectoriesIfNecessary() } diff --git a/Meshtastic/Persistence/UpdateCoreData.swift b/Meshtastic/Persistence/UpdateCoreData.swift index e7f9567c..4073eb90 100644 --- a/Meshtastic/Persistence/UpdateCoreData.swift +++ b/Meshtastic/Persistence/UpdateCoreData.swift @@ -353,7 +353,7 @@ func upsertPositionPacket (packet: MeshPacket, context: NSManagedObjectContext) do { try context.save() - Logger.data.info("💾 Updated Node Position Coordinates from Position App Packet For: \(fetchedNode[0].num.toHex(), privacy: .public)") + Logger.data.info("💾 [Position] Saved from Position App Packet For: \(fetchedNode[0].num.toHex(), privacy: .public)") } catch { context.rollback() let nsError = error as NSError diff --git a/Meshtastic/Views/Settings/Logs/AppLogFilter.swift b/Meshtastic/Views/Settings/Logs/AppLogFilter.swift index 5dfa699a..46d6f838 100644 --- a/Meshtastic/Views/Settings/Logs/AppLogFilter.swift +++ b/Meshtastic/Views/Settings/Logs/AppLogFilter.swift @@ -81,7 +81,7 @@ enum LogLevels: Int, CaseIterable, Identifiable { var color: Color { switch self { case .debug: - return .blue + return .indigo case .info: return .green case .notice: