aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/WireGuard
diff options
context:
space:
mode:
Diffstat (limited to 'WireGuard/WireGuard')
-rw-r--r--WireGuard/WireGuard/UI/iOS/AppDelegate.swift8
-rw-r--r--WireGuard/WireGuard/UI/iOS/SettingsTableViewController.swift18
-rw-r--r--WireGuard/WireGuard/WireGuard-Bridging-Header.h1
3 files changed, 16 insertions, 11 deletions
diff --git a/WireGuard/WireGuard/UI/iOS/AppDelegate.swift b/WireGuard/WireGuard/UI/iOS/AppDelegate.swift
index 1a4f15c..5625814 100644
--- a/WireGuard/WireGuard/UI/iOS/AppDelegate.swift
+++ b/WireGuard/WireGuard/UI/iOS/AppDelegate.swift
@@ -13,6 +13,14 @@ 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)
+ }
+
let window = UIWindow(frame: UIScreen.main.bounds)
window.backgroundColor = UIColor.white
self.window = window
diff --git a/WireGuard/WireGuard/UI/iOS/SettingsTableViewController.swift b/WireGuard/WireGuard/UI/iOS/SettingsTableViewController.swift
index fe276b1..43e277e 100644
--- a/WireGuard/WireGuard/UI/iOS/SettingsTableViewController.swift
+++ b/WireGuard/WireGuard/UI/iOS/SettingsTableViewController.swift
@@ -108,23 +108,19 @@ class SettingsTableViewController: UITableViewController {
if FileManager.default.fileExists(atPath: destinationURL.path) {
let isDeleted = FileManager.deleteFile(at: destinationURL)
if !isDeleted {
- ErrorPresenter.showErrorAlert(title: "No log available", message: "The pre-existing log could not be cleared", from: self)
+ ErrorPresenter.showErrorAlert(title: "Log export failed", message: "The pre-existing log could not be cleared", from: self)
return
}
}
- guard let networkExtensionLogFileURL = FileManager.networkExtensionLogFileURL,
- FileManager.default.fileExists(atPath: networkExtensionLogFileURL.path) else {
- ErrorPresenter.showErrorAlert(title: "No log available", message: "Please activate a tunnel and then export the log", from: self)
- return
+ guard let networkExtensionLogFilePath = FileManager.networkExtensionLogFileURL?.path else {
+ ErrorPresenter.showErrorAlert(title: "Log export failed", message: "Internal error obtaining extension log path", from: self)
+ return
}
- do {
- try FileManager.default.copyItem(at: networkExtensionLogFileURL, to: destinationURL)
- } catch {
- os_log("Failed to copy file: %{public}@ to %{public}@: %{public}@", log: OSLog.default, type: .error,
- networkExtensionLogFileURL.absoluteString, destinationURL.absoluteString, error.localizedDescription)
- ErrorPresenter.showErrorAlert(title: "Log export failed", message: "The log could not be copied", from: self)
+ let isWritten = Logger.writeLog(mergedWith: networkExtensionLogFilePath, to: destinationURL.path)
+ guard isWritten else {
+ ErrorPresenter.showErrorAlert(title: "Log export failed", message: "Internal error merging logs", from: self)
return
}
diff --git a/WireGuard/WireGuard/WireGuard-Bridging-Header.h b/WireGuard/WireGuard/WireGuard-Bridging-Header.h
index 4fe53a7..21cd2a2 100644
--- a/WireGuard/WireGuard/WireGuard-Bridging-Header.h
+++ b/WireGuard/WireGuard/WireGuard-Bridging-Header.h
@@ -2,3 +2,4 @@
#include "unzip.h"
#include "zip.h"
#include "wireguard-go-version.h"
+#include "ringlogger.h"