mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Colorful logs
This commit is contained in:
parent
7aa9bbf497
commit
d0d383f5ce
4 changed files with 33 additions and 4 deletions
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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!
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue