diff --git a/Meshtastic/Extensions/Logger.swift b/Meshtastic/Extensions/Logger.swift index 9dc12a88..95817ea4 100644 --- a/Meshtastic/Extensions/Logger.swift +++ b/Meshtastic/Extensions/Logger.swift @@ -6,6 +6,7 @@ // import OSLog +import SwiftUI extension Logger { @@ -71,4 +72,15 @@ extension OSLogEntryLog.Level { @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/Helpers/BLEManager.swift b/Meshtastic/Helpers/BLEManager.swift index ecac0aa5..e9fce916 100644 --- a/Meshtastic/Helpers/BLEManager.swift +++ b/Meshtastic/Helpers/BLEManager.swift @@ -848,7 +848,7 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate invalidVersion = false lastConnectionError = "" isSubscribed = true - Logger.mesh.info("[BLE] 🤜 Want Config Complete. ID:\(decodedInfo.configCompleteID)") + Logger.mesh.info("🤜 [BLE] Want Config Complete. ID:\(decodedInfo.configCompleteID)") peripherals.removeAll(where: { $0.peripheral.state == CBPeripheralState.disconnected }) // Config conplete returns so we don't read the characteristic again diff --git a/Meshtastic/Views/Settings/AppLog.swift b/Meshtastic/Views/Settings/AppLog.swift index a3dcd59d..975a302e 100644 --- a/Meshtastic/Views/Settings/AppLog.swift +++ b/Meshtastic/Views/Settings/AppLog.swift @@ -9,7 +9,7 @@ import SwiftUI import OSLog /// Needed for TableColumnForEach -@available(iOS 17.4, *) +@available(iOS 17.4, macOS 14.4, *) struct AppLog: View { @State private var logs: [OSLogEntryLog] = [] @@ -40,15 +40,17 @@ struct AppLog: View { Text(value.date.formatted(dateFormatStyle)) } .width(min: 125, max: 150) - TableColumn("log.category", value: \.category) - .width(min: 125, max: 150) TableColumn("log.level") { value in Text(value.level.description) + .foregroundStyle(value.level.color) } .width(min: 75, max: 100) + TableColumn("log.category", value: \.category) + .width(min: 125, max: 150) } TableColumn("log.message", value: \.composedMessage) { value in Text(value.composedMessage) + .foregroundStyle(value.level.color) .font(idiom == .phone ? .caption : .body) } .width(ideal: 200, max: .infinity) diff --git a/Meshtastic/Views/Settings/Logs/AppLogFilter.swift b/Meshtastic/Views/Settings/Logs/AppLogFilter.swift index fa3a41e6..5dfa699a 100644 --- a/Meshtastic/Views/Settings/Logs/AppLogFilter.swift +++ b/Meshtastic/Views/Settings/Logs/AppLogFilter.swift @@ -78,6 +78,20 @@ enum LogLevels: Int, CaseIterable, Identifiable { return "💥 Fault" } } + var color: Color { + switch self { + case .debug: + return .blue + case .info: + return .green + case .notice: + return .orange + case .error: + return .red + case .fault: + return .red + } + } } struct AppLogFilter: View { @@ -107,6 +121,7 @@ struct AppLogFilter: View { VStack { List(LogLevels.allCases, selection: $levels) { level in Text(level.description) + .foregroundStyle(level.color) } .listStyle(.plain) .environment(\.editMode, $editMode) /// bind it here!