From bb0f9e0baf684e58cb445b4a3766ee39d48a09f0 Mon Sep 17 00:00:00 2001 From: Erik Gomez Date: Tue, 16 Jul 2024 17:33:14 -0500 Subject: [PATCH] get rid of all prints and log properly --- Nudge/UI/Main.swift | 10 +++++----- Nudge/Utilities/Preferences.swift | 12 ++++++------ Nudge/Utilities/UILogic.swift | 2 +- Nudge/Utilities/Utils.swift | 8 ++++---- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Nudge/UI/Main.swift b/Nudge/UI/Main.swift index 4c704f41..a64ec104 100644 --- a/Nudge/UI/Main.swift +++ b/Nudge/UI/Main.swift @@ -439,7 +439,7 @@ class AppDelegate: NSObject, NSApplicationDelegate { } } } else { - print("applicationTerminatedNotificationImagePath does not exist on disk, skipping notification image.") + LogManager.error("applicationTerminatedNotificationImagePath does not exist on disk, skipping notification image.", logger: uiLog) } return content } @@ -621,7 +621,7 @@ class AppDelegate: NSObject, NSApplicationDelegate { object: NSApplication.shared, queue: .main) { _ in if UserExperienceVariables.allowMovableWindow { return } - print("Window object frame moved - Notification Center") + LogManager.debug("Window object frame moved - Notification Center", logger: utilsLog) UIUtilities().centerNudge() } } @@ -732,17 +732,17 @@ class AppDelegate: NSObject, NSApplicationDelegate { class WindowDelegate: NSObject, NSWindowDelegate { func windowDidMove(_ notification: Notification) { if UserExperienceVariables.allowMovableWindow { return } - print("Window attempted to move - Window Delegate") + LogManager.debug("Window attempted to move - Window Delegate", logger: utilsLog) UIUtilities().centerNudge() } func windowDidChangeScreen(_ notification: Notification) { if UserExperienceVariables.allowMovableWindow { return } - print("Window moved screens - Window Delegate") + LogManager.debug("Window moved screens - Window Delegate", logger: utilsLog) UIUtilities().centerNudge() } func windowDidChangeScreenProfile(_ notification: Notification) { if UserExperienceVariables.allowMovableWindow { return } - print("Display has changed profiles - Window Delegate") + LogManager.debug("Display has changed profiles - Window Delegate", logger: utilsLog) UIUtilities().centerNudge() } } diff --git a/Nudge/Utilities/Preferences.swift b/Nudge/Utilities/Preferences.swift index 9bdef871..fdbd1288 100644 --- a/Nudge/Utilities/Preferences.swift +++ b/Nudge/Utilities/Preferences.swift @@ -34,7 +34,7 @@ func getDesiredLanguage(locale: Locale? = nil) -> String { } } } catch { - print("Failed to decode plist: \(error)") + LogManager.error("Failed to decode plist: \(error)", logger: prefsProfileLog) } } return UserInterfaceVariables.fallbackLanguage @@ -81,7 +81,7 @@ func getOptionalFeaturesProfile() -> [String: Any]? { return nil } } catch { - print("Failed to decode plist: \(error)") + LogManager.error("Failed to decode plist: \(error)", logger: prefsProfileLog) return nil } } @@ -150,7 +150,7 @@ func getOSVersionRequirementsProfile() -> OSVersionRequirement? { return nil } } catch { - print("Failed to decode plist: \(error)") + LogManager.error("Failed to decode plist: \(error)", logger: prefsProfileLog) return nil } } @@ -240,7 +240,7 @@ func getUserExperienceProfile() -> [String: Any]? { return nil } } catch { - print("Failed to decode plist: \(error)") + LogManager.error("Failed to decode plist: \(error)", logger: prefsProfileLog) return nil } } @@ -288,7 +288,7 @@ func getUserInterfaceProfile() -> [String: Any]? { return nil } } catch { - print("Failed to decode plist: \(error)") + LogManager.error("Failed to decode plist: \(error)", logger: prefsProfileLog) return nil } } @@ -332,7 +332,7 @@ func getUserInterfaceUpdateElementsProfile() -> [String: AnyObject]? { return nil } } catch { - print("Failed to decode plist: \(error)") + LogManager.error("Failed to decode plist: \(error)", logger: prefsProfileLog) return nil } } diff --git a/Nudge/Utilities/UILogic.swift b/Nudge/Utilities/UILogic.swift index c06255d6..d84dd827 100644 --- a/Nudge/Utilities/UILogic.swift +++ b/Nudge/Utilities/UILogic.swift @@ -301,7 +301,7 @@ func isSnapshotPresent(snapshotName: String) -> Bool { let result = subProcessUtilities.runProcess(launchPath: "/usr/sbin/diskutil", arguments: ["apfs", "listSnapshots", "/"]) if result.exitCode != 0 { - print("Error: \(result.error)") + LogManager.error("Error: \(result.error)", logger: utilsLog) return false } diff --git a/Nudge/Utilities/Utils.swift b/Nudge/Utilities/Utils.swift index 3b9c3d6b..c9f0fac7 100644 --- a/Nudge/Utilities/Utils.swift +++ b/Nudge/Utilities/Utils.swift @@ -225,7 +225,7 @@ struct AppStateManager { if let value = CFPreferencesCopyAppValue(key, appID) as? Bool { return value } else { - print("Key '\(key)' not found in preferences") + LogManager.info("Key '\(key)' not found in preferences", logger: uiLog) return false } @@ -988,7 +988,7 @@ struct NetworkFileManager { try fileManager.removeItem(atPath: sofaPath.path) sofaJSONExists = false } catch { - print("Error deleting file: \(error.localizedDescription)") + LogManager.error("Error deleting file: \(error.localizedDescription)", logger: sofaLog) } } } @@ -1055,7 +1055,7 @@ struct NetworkFileManager { try fileManager.removeItem(atPath: sofaPath.path) sofaJSONExists = false } catch { - print("Error deleting file: \(error.localizedDescription)") + LogManager.error("Error deleting file: \(error.localizedDescription)", logger: sofaLog) } LogManager.error("Failed to decode sofa JSON: \(error.localizedDescription)", logger: sofaLog) LogManager.error("Failed to decode sofa JSON: \(error)", logger: sofaLog) @@ -1129,7 +1129,7 @@ struct NetworkFileManager { return fileSize.intValue == 0 } } catch { - print("Error getting file attributes: \(error.localizedDescription)") + LogManager.error("Error getting file attributes: \(error.localizedDescription)", logger: prefsJSONLog) } return false }