From cd0f7dd9d603b8f574dcd1056da56d3d558de597 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Mon, 3 Jun 2024 10:23:20 -0700 Subject: [PATCH] Emoji in the logs --- Meshtastic/Helpers/BLEManager.swift | 6 +++--- Meshtastic/Helpers/LocationsHandler.swift | 12 ++++++------ Meshtastic/Helpers/Logger.swift | 13 +++++-------- Meshtastic/MeshtasticApp.swift | 11 +++++------ 4 files changed, 19 insertions(+), 23 deletions(-) diff --git a/Meshtastic/Helpers/BLEManager.swift b/Meshtastic/Helpers/BLEManager.swift index 36989936..caab235d 100644 --- a/Meshtastic/Helpers/BLEManager.swift +++ b/Meshtastic/Helpers/BLEManager.swift @@ -62,7 +62,7 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate func startScanning() { if isSwitchedOn { centralManager.scanForPeripherals(withServices: [meshtasticServiceCBUUID], options: [CBCentralManagerScanOptionAllowDuplicatesKey: false]) - Logger.data.info("βœ… Scanning Started") + Logger.services.info("βœ… Scanning Started") } } @@ -2988,7 +2988,7 @@ extension BLEManager: CBCentralManagerDelegate { // MARK: Bluetooth enabled/disabled func centralManagerDidUpdateState(_ central: CBCentralManager) { if central.state == CBManagerState.poweredOn { - Logger.services.debug("BLE powered on") + Logger.services.debug("πŸ”Œ BLE powered on") isSwitchedOn = true startScanning() } else { @@ -3013,7 +3013,7 @@ extension BLEManager: CBCentralManagerDelegate { default: status = "default" } - Logger.services.debug("BLEManager status: \(status)") + Logger.services.debug("πŸ“œ BLEManager status: \(status)") } // Called each time a peripheral is discovered diff --git a/Meshtastic/Helpers/LocationsHandler.swift b/Meshtastic/Helpers/LocationsHandler.swift index d4f0ba94..32fc88d9 100644 --- a/Meshtastic/Helpers/LocationsHandler.swift +++ b/Meshtastic/Helpers/LocationsHandler.swift @@ -50,7 +50,7 @@ import OSLog if self.manager.authorizationStatus == .notDetermined { self.manager.requestWhenInUseAuthorization() } - Logger.services.info("Starting location updates") + Logger.services.info("πŸ“ Starting location updates") Task { do { self.updatesStarted = true @@ -70,14 +70,14 @@ import OSLog } } } catch { - Logger.services.error("Could not start location updates: \(error.localizedDescription)") + Logger.services.error("πŸ’₯ Could not start location updates: \(error.localizedDescription)") } return } } func stopLocationUpdates() { - Logger.services.info("Stopping location updates") + Logger.services.info("πŸ›‘ Stopping location updates") self.updatesStarted = false } @@ -85,15 +85,15 @@ import OSLog if smartPostion { let age = -location.timestamp.timeIntervalSinceNow if age > 10 { - Logger.services.warning("Bad Location \(self.count): Too Old \(age) seconds ago \(location)") + Logger.services.warning("πŸ“ Bad Location \(self.count): Too Old \(age) seconds ago \(location)") return false } if location.horizontalAccuracy < 0 { - Logger.services.warning("Bad Location \(self.count): Horizontal Accuracy: \(location.horizontalAccuracy) \(location)") + Logger.services.warning("πŸ“ Bad Location \(self.count): Horizontal Accuracy: \(location.horizontalAccuracy) \(location)") return false } if location.horizontalAccuracy > 5 { - Logger.services.warning("Bad Location \(self.count): Horizontal Accuracy: \(location.horizontalAccuracy) \(location)") + Logger.services.warning("πŸ“ Bad Location \(self.count): Horizontal Accuracy: \(location.horizontalAccuracy) \(location)") return false } } diff --git a/Meshtastic/Helpers/Logger.swift b/Meshtastic/Helpers/Logger.swift index a273d2f3..c94a6003 100644 --- a/Meshtastic/Helpers/Logger.swift +++ b/Meshtastic/Helpers/Logger.swift @@ -5,18 +5,15 @@ extension Logger { /// The logger's subsystem. private static var subsystem = Bundle.main.bundleIdentifier! - // NOTE: Replace the categories below with your own choosing. - /// All logs related to data such as decoding error, parsing issues, etc. - static let data = Logger(subsystem: subsystem, category: "data") + static let data = Logger(subsystem: subsystem, category: "πŸ—„οΈ Data") - /// All logs related to data such as decoding error, parsing issues, etc. - static let mesh = Logger(subsystem: subsystem, category: "mesh") + /// All logs related to the mesh + static let mesh = Logger(subsystem: subsystem, category: "πŸ•ΈοΈ Mesh") /// All logs related to services such as network calls, location, etc. - static let services = Logger(subsystem: subsystem, category: "services") + static let services = Logger(subsystem: subsystem, category: "🍏 Services") /// All logs related to tracking and analytics. - static let statistics = Logger(subsystem: subsystem, category: "statistics") - + static let statistics = Logger(subsystem: subsystem, category: "πŸ“ˆ Stats") } diff --git a/Meshtastic/MeshtasticApp.swift b/Meshtastic/MeshtasticApp.swift index d52419a9..da3383d2 100644 --- a/Meshtastic/MeshtasticApp.swift +++ b/Meshtastic/MeshtasticApp.swift @@ -140,7 +140,7 @@ struct MeshtasticAppleApp: App { .onChange(of: scenePhase) { (newScenePhase) in switch newScenePhase { case .background: - Logger.services.info("Scene is in the background") + Logger.services.info("🍏 Scene is in the background") do { try persistenceController.container.viewContext.save() @@ -148,14 +148,14 @@ struct MeshtasticAppleApp: App { } catch { - Logger.services.error("Failed to save viewContext when the app goes to the background.") + Logger.services.error("πŸ’₯ Failed to save viewContext when the app goes to the background.") } case .inactive: - Logger.services.info("Scene is inactive") + Logger.services.info("🍏 Scene is inactive") case .active: - Logger.services.info("Scene is active") + Logger.services.info("🍏 Scene is active") @unknown default: - Logger.services.error("Apple must have changed something") + Logger.services.error("🍎 Apple must have changed something") } } } @@ -168,6 +168,5 @@ class AppState: ObservableObject { @Published var unreadDirectMessages: Int = 0 @Published var unreadChannelMessages: Int = 0 @Published var firmwareVersion: String = "0.0.0" - // @Published var connectedNode: NodeInfoEntity? @Published var navigationPath: String? }