From 642b627d277cdb30b91682ba29b5c3a226d607d9 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Thu, 13 Dec 2018 15:26:04 +0100 Subject: Rewrite Logger This reverts all of Roop's changes to the C code, and then rewrites the logger logic to be cleaner. Signed-off-by: Jason A. Donenfeld --- WireGuard/WireGuard/UI/iOS/AppDelegate.swift | 12 +----------- WireGuard/WireGuard/UI/iOS/SettingsTableViewController.swift | 6 +++--- 2 files changed, 4 insertions(+), 14 deletions(-) (limited to 'WireGuard/WireGuard') diff --git a/WireGuard/WireGuard/UI/iOS/AppDelegate.swift b/WireGuard/WireGuard/UI/iOS/AppDelegate.swift index a5856e0..32c1286 100644 --- a/WireGuard/WireGuard/UI/iOS/AppDelegate.swift +++ b/WireGuard/WireGuard/UI/iOS/AppDelegate.swift @@ -12,17 +12,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { - - if let appLogFilePath = FileManager.appLogFileURL?.path { - if !Logger.configure(withFilePath: appLogFilePath) { - os_log("Can't open log file for writing. Log is not saved to file.", log: OSLog.default, type: .error) - } - } else { - os_log("Can't obtain log file URL. Log is not saved to file.", log: OSLog.default, type: .error) - } - - wg_log(.info, message: "Launching app") - wg_log_versions_to_file() + Logger.configureGlobal(withFilePath: FileManager.appLogFileURL?.path, withTag: "APP") let window = UIWindow(frame: UIScreen.main.bounds) window.backgroundColor = UIColor.white diff --git a/WireGuard/WireGuard/UI/iOS/SettingsTableViewController.swift b/WireGuard/WireGuard/UI/iOS/SettingsTableViewController.swift index 2d17224..af9893d 100644 --- a/WireGuard/WireGuard/UI/iOS/SettingsTableViewController.swift +++ b/WireGuard/WireGuard/UI/iOS/SettingsTableViewController.swift @@ -115,13 +115,13 @@ class SettingsTableViewController: UITableViewController { } guard let networkExtensionLogFilePath = FileManager.networkExtensionLogFileURL?.path else { - ErrorPresenter.showErrorAlert(title: "Log export failed", message: "Internal error obtaining extension log path", from: self) + ErrorPresenter.showErrorAlert(title: "Log export failed", message: "Unable to determine extension log path", from: self) return } - let isWritten = Logger.writeLog(mergedWith: networkExtensionLogFilePath, tag: "APP", otherTag: "EXT", to: destinationURL.path) + let isWritten = Logger.global?.writeLog(mergedWith: networkExtensionLogFilePath, to: destinationURL.path) ?? false guard isWritten else { - ErrorPresenter.showErrorAlert(title: "Log export failed", message: "Internal error merging logs", from: self) + ErrorPresenter.showErrorAlert(title: "Log export failed", message: "Unable to write logs to file", from: self) return } -- cgit v1.2.3-59-g8ed1b