From 53d5f4bc7c12cfcf62f728c0d774913ae7ff29dc Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Mon, 29 Jul 2024 20:43:01 -0700 Subject: [PATCH 1/5] Add debug to meshlog and appdata views --- Meshtastic/Views/Settings/Settings.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Meshtastic/Views/Settings/Settings.swift b/Meshtastic/Views/Settings/Settings.swift index faad71ad..53bc5eb2 100644 --- a/Meshtastic/Views/Settings/Settings.swift +++ b/Meshtastic/Views/Settings/Settings.swift @@ -469,13 +469,17 @@ struct Settings: View { case .telemetry: TelemetryConfig(node: node) case .meshLog: +#if DEBUG MeshLog() +#endif case .debugLogs: if #available(iOS 17.4, *) { AppLog() } case .appFiles: +#if DEBUG AppData() +#endif case .firmwareUpdates: Firmware(node: node) } From 447d82030af77562f438eeedf83cd812b209be2f Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Tue, 30 Jul 2024 13:48:08 -0700 Subject: [PATCH 2/5] Log Cleanup --- Localizable.xcstrings | 3 - Meshtastic/Helpers/MeshPackets.swift | 2 +- Meshtastic/Views/Settings/AppLog.swift | 147 +++++++++++++++-------- Meshtastic/Views/Settings/MeshLog.swift | 2 +- Meshtastic/Views/Settings/Settings.swift | 25 ++-- 5 files changed, 106 insertions(+), 73 deletions(-) diff --git a/Localizable.xcstrings b/Localizable.xcstrings index d0857465..a2953404 100644 --- a/Localizable.xcstrings +++ b/Localizable.xcstrings @@ -5052,9 +5052,6 @@ }, "Debug Log" : { - }, - "Debug Logs" : { - }, "Debug Logs%@" : { diff --git a/Meshtastic/Helpers/MeshPackets.swift b/Meshtastic/Helpers/MeshPackets.swift index 5ee37673..0d6f5917 100644 --- a/Meshtastic/Helpers/MeshPackets.swift +++ b/Meshtastic/Helpers/MeshPackets.swift @@ -670,7 +670,7 @@ func telemetryPacket(packet: MeshPacket, connectedNode: Int64, context: NSManage telemetry.voltage = telemetryMessage.deviceMetrics.voltage telemetry.uptimeSeconds = Int32(telemetryMessage.deviceMetrics.uptimeSeconds) telemetry.metricsType = 0 - Logger.statistics.info("📈 [Mesh Statistics] Channel Utilization: \(telemetryMessage.deviceMetrics.channelUtilization, privacy: .public) Airtime: \(telemetryMessage.deviceMetrics.airUtilTx, privacy: .public) for Node: \(packet.from.toHex(), privacy: .public))") + Logger.statistics.info("📈 [Mesh Statistics] Channel Utilization: \(telemetryMessage.deviceMetrics.channelUtilization, privacy: .public) Airtime: \(telemetryMessage.deviceMetrics.airUtilTx, privacy: .public) for Node: \(packet.from.toHex(), privacy: .public)") } else if telemetryMessage.variant == Telemetry.OneOf_Variant.environmentMetrics(telemetryMessage.environmentMetrics) { // Environment Metrics telemetry.barometricPressure = telemetryMessage.environmentMetrics.barometricPressure diff --git a/Meshtastic/Views/Settings/AppLog.swift b/Meshtastic/Views/Settings/AppLog.swift index 2ed2b081..2ade781c 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, macOS 14.4, *) +@available(iOS 17.0, macOS 14.0, *) struct AppLog: View { @State private var logs: [OSLogEntryLog] = [] @@ -33,60 +33,101 @@ struct AppLog: View { .secondFraction(.fractional(3)) var body: some View { - - Table(logs, selection: $selection, sortOrder: $sortOrder) { - if idiom != .phone { - TableColumn("log.time") { value in - Text(value.date.formatted(dateFormatStyle)) - } - .width(min: 125, max: 150) - TableColumn("log.level") { value in - Text(value.level.description) - .foregroundStyle(value.level.color) - } - .width(min: 85, max: 110) - TableColumn("log.category", value: \.category) - .width(min: 80, max: 130) - } - TableColumn("log.message", value: \.composedMessage) { value in - Text(value.composedMessage) - .foregroundStyle(value.level.color) - .font(idiom == .phone ? .caption : .body) - } - .width(ideal: 200, max: .infinity) - } - .monospaced() - - .safeAreaInset(edge: .bottom, alignment: .trailing) { - HStack { - Button(action: { - withAnimation { - isEditingFilters = !isEditingFilters + HStack { + + if idiom == .phone { + Table(logs, selection: $selection, sortOrder: $sortOrder) { + TableColumn("log.message", value: \.composedMessage) { value in + Text(value.composedMessage) + .foregroundStyle(value.level.color) + .font(idiom == .phone ? .caption : .body) } - }) { - Image(systemName: !isEditingFilters ? "line.3.horizontal.decrease.circle" : "line.3.horizontal.decrease.circle.fill") - .padding(.vertical, 5) + .width(ideal: 200, max: .infinity) + } + .monospaced() + .safeAreaInset(edge: .bottom, alignment: .trailing) { + HStack { + Button(action: { + withAnimation { + isEditingFilters = !isEditingFilters + } + }) { + Image(systemName: !isEditingFilters ? "line.3.horizontal.decrease.circle" : "line.3.horizontal.decrease.circle.fill") + .padding(.vertical, 5) + } + .tint(Color(UIColor.secondarySystemBackground)) + .foregroundColor(.accentColor) + .buttonStyle(.borderedProminent) + + } + .controlSize(.regular) + .padding(5) + } + .padding(.bottom, 5) + .padding(.trailing, 5) + .searchable(text: $searchText, placement: .navigationBarDrawer, prompt: "Search") + .disabled(selection != nil) + .overlay { + if logs.isEmpty { + ContentUnavailableView("No Logs Available", systemImage: "scroll") + } + } + .refreshable { + await logs = searchAppLogs() + logs.sort(using: sortOrder) + } + } else { + Table(logs, selection: $selection, sortOrder: $sortOrder) { + TableColumn("log.time") { value in + Text(value.date.formatted(dateFormatStyle)) + } + .width(min: 125, max: 150) + TableColumn("log.level") { value in + Text(value.level.description) + .foregroundStyle(value.level.color) + } + .width(min: 85, max: 110) + TableColumn("log.category", value: \.category) + .width(min: 80, max: 130) + TableColumn("log.message", value: \.composedMessage) { value in + Text(value.composedMessage) + .foregroundStyle(value.level.color) + .font(idiom == .phone ? .caption : .body) + } + .width(ideal: 200, max: .infinity) + } + .monospaced() + .safeAreaInset(edge: .bottom, alignment: .trailing) { + HStack { + Button(action: { + withAnimation { + isEditingFilters = !isEditingFilters + } + }) { + Image(systemName: !isEditingFilters ? "line.3.horizontal.decrease.circle" : "line.3.horizontal.decrease.circle.fill") + .padding(.vertical, 5) + } + .tint(Color(UIColor.secondarySystemBackground)) + .foregroundColor(.accentColor) + .buttonStyle(.borderedProminent) + } + .controlSize(.regular) + .padding(5) + } + .padding(.bottom, 5) + .padding(.trailing, 5) + .searchable(text: $searchText, placement: .navigationBarDrawer, prompt: "Search") + .disabled(selection != nil) + .overlay { + if logs.isEmpty { + ContentUnavailableView("No Logs Available", systemImage: "scroll") + } + } + .refreshable { + await logs = searchAppLogs() + logs.sort(using: sortOrder) } - .tint(Color(UIColor.secondarySystemBackground)) - .foregroundColor(.accentColor) - .buttonStyle(.borderedProminent) - } - .controlSize(.regular) - .padding(5) - } - .padding(.bottom, 5) - .padding(.trailing, 5) - .searchable(text: $searchText, placement: .navigationBarDrawer, prompt: "Search") - .disabled(selection != nil) - .overlay { - if logs.isEmpty { - ContentUnavailableView("No Logs Available", systemImage: "scroll") - } - } - .refreshable { - await logs = searchAppLogs() - logs.sort(using: sortOrder) } .onChange(of: sortOrder) { _, sortOrder in withAnimation { @@ -176,7 +217,7 @@ struct AppLog: View { } } -@available(iOS 17.4, macOS 14.4, *) +@available(iOS 17.0, macOS 14.0, *) extension AppLog { @MainActor private func searchAppLogs() async -> [OSLogEntryLog] { diff --git a/Meshtastic/Views/Settings/MeshLog.swift b/Meshtastic/Views/Settings/MeshLog.swift index da2b5014..e63c2f34 100644 --- a/Meshtastic/Views/Settings/MeshLog.swift +++ b/Meshtastic/Views/Settings/MeshLog.swift @@ -18,7 +18,7 @@ struct MeshLog: View { let url = logFile! logs.removeAll() var lineCount = 0 - let lineLimit = 1000 + let lineLimit = 10000 // Get the number of lines for try await _ in url.lines { lineCount += 1 diff --git a/Meshtastic/Views/Settings/Settings.swift b/Meshtastic/Views/Settings/Settings.swift index 53bc5eb2..414daf0f 100644 --- a/Meshtastic/Views/Settings/Settings.swift +++ b/Meshtastic/Views/Settings/Settings.swift @@ -243,20 +243,12 @@ struct Settings: View { var loggingSection: some View { Section(header: Text("logging")) { - NavigationLink(value: SettingsNavigationState.meshLog) { - Label { - Text("mesh.log") - } icon: { - Image(systemName: "list.bullet.rectangle") - } - } - - if #available (iOS 17.4, *) { + if #available (iOS 17.0, *) { NavigationLink(value: SettingsNavigationState.debugLogs) { Label { - Text("Debug Logs") + Text("Logs") } icon: { - Image(systemName: "stethoscope") + Image(systemName: "scroll") } } } @@ -265,6 +257,13 @@ struct Settings: View { var developersSection: some View { Section(header: Text("Developers")) { + NavigationLink(value: SettingsNavigationState.meshLog) { + Label { + Text("mesh.log") + } icon: { + Image(systemName: "list.bullet.rectangle") + } + } NavigationLink(value: SettingsNavigationState.appFiles) { Label { Text("App Files") @@ -469,17 +468,13 @@ struct Settings: View { case .telemetry: TelemetryConfig(node: node) case .meshLog: -#if DEBUG MeshLog() -#endif case .debugLogs: if #available(iOS 17.4, *) { AppLog() } case .appFiles: -#if DEBUG AppData() -#endif case .firmwareUpdates: Firmware(node: node) } From ae5e0c946e461f5f1f66b797edd801d92c6f8c0b Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Tue, 30 Jul 2024 19:13:09 -0700 Subject: [PATCH 3/5] remove conditional fonts --- Meshtastic/Views/Settings/AppLog.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Meshtastic/Views/Settings/AppLog.swift b/Meshtastic/Views/Settings/AppLog.swift index 2ade781c..0a2aaad0 100644 --- a/Meshtastic/Views/Settings/AppLog.swift +++ b/Meshtastic/Views/Settings/AppLog.swift @@ -34,13 +34,13 @@ struct AppLog: View { var body: some View { HStack { - + if idiom == .phone { Table(logs, selection: $selection, sortOrder: $sortOrder) { TableColumn("log.message", value: \.composedMessage) { value in Text(value.composedMessage) .foregroundStyle(value.level.color) - .font(idiom == .phone ? .caption : .body) + .font(.caption) } .width(ideal: 200, max: .infinity) } @@ -92,7 +92,7 @@ struct AppLog: View { TableColumn("log.message", value: \.composedMessage) { value in Text(value.composedMessage) .foregroundStyle(value.level.color) - .font(idiom == .phone ? .caption : .body) + .font(.body) } .width(ideal: 200, max: .infinity) } From f5e48a577600724813c39802a9c8c5933f12fdae Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Tue, 30 Jul 2024 21:27:42 -0700 Subject: [PATCH 4/5] Fix setting display availability --- Meshtastic/Views/Settings/Settings.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Meshtastic/Views/Settings/Settings.swift b/Meshtastic/Views/Settings/Settings.swift index 414daf0f..b141f997 100644 --- a/Meshtastic/Views/Settings/Settings.swift +++ b/Meshtastic/Views/Settings/Settings.swift @@ -444,7 +444,7 @@ struct Settings: View { case .power: PowerConfig(node: node) case .ambientLighting: - if #available(iOS 17.0, *) { + if #available(iOS 17.0, macOS 14.0, *) { AmbientLightingConfig(node: node) } case .cannedMessages: @@ -470,7 +470,7 @@ struct Settings: View { case .meshLog: MeshLog() case .debugLogs: - if #available(iOS 17.4, *) { + if #available(iOS 17.0, macOS 14.0, *) { AppLog() } case .appFiles: From 9bd0021facffa5e7167a2676c900be0d33e579e0 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Tue, 30 Jul 2024 21:37:18 -0700 Subject: [PATCH 5/5] Content unavailable updates --- Localizable.xcstrings | 6 +++--- Meshtastic/Views/Settings/AppLog.swift | 5 ++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Localizable.xcstrings b/Localizable.xcstrings index a2953404..f5642a53 100644 --- a/Localizable.xcstrings +++ b/Localizable.xcstrings @@ -10849,6 +10849,9 @@ }, "Line Series" : { + }, + "Loading Logs. . ." : { + }, "Location: %@" : { @@ -15301,9 +15304,6 @@ }, "No Environment Metrics" : { - }, - "No Logs Available" : { - }, "No Positions" : { diff --git a/Meshtastic/Views/Settings/AppLog.swift b/Meshtastic/Views/Settings/AppLog.swift index 0a2aaad0..fd3db810 100644 --- a/Meshtastic/Views/Settings/AppLog.swift +++ b/Meshtastic/Views/Settings/AppLog.swift @@ -58,7 +58,6 @@ struct AppLog: View { .tint(Color(UIColor.secondarySystemBackground)) .foregroundColor(.accentColor) .buttonStyle(.borderedProminent) - } .controlSize(.regular) .padding(5) @@ -69,7 +68,7 @@ struct AppLog: View { .disabled(selection != nil) .overlay { if logs.isEmpty { - ContentUnavailableView("No Logs Available", systemImage: "scroll") + ContentUnavailableView("Loading Logs. . .", systemImage: "scroll") } } .refreshable { @@ -120,7 +119,7 @@ struct AppLog: View { .disabled(selection != nil) .overlay { if logs.isEmpty { - ContentUnavailableView("No Logs Available", systemImage: "scroll") + ContentUnavailableView("Loading Logs. . .", systemImage: "scroll") } } .refreshable {