diff options
| author | Andrej Mihajlov <and@mullvad.net> | 2020-08-26 14:29:23 +0200 |
|---|---|---|
| committer | Andrej Mihajlov <and@mullvad.net> | 2020-09-02 13:52:40 +0200 |
| commit | 531cc8490eb1999cd382bace0e2e90ed7ed3f794 (patch) | |
| tree | 0c16842f557352f512dffd7cd95d920907a85d6f /ios | |
| parent | 65169241a72b7379e0eb5ca7d9b5a7a0f491603d (diff) | |
| download | mullvadvpn-531cc8490eb1999cd382bace0e2e90ed7ed3f794.tar.xz mullvadvpn-531cc8490eb1999cd382bace0e2e90ed7ed3f794.zip | |
AppDelegate: forward packet tunnel logs and print them to stdout in DEBUG
Diffstat (limited to 'ios')
| -rw-r--r-- | ios/MullvadVPN/AppDelegate.swift | 11 | ||||
| -rw-r--r-- | ios/MullvadVPN/ApplicationConfiguration.swift | 27 |
2 files changed, 28 insertions, 10 deletions
diff --git a/ios/MullvadVPN/AppDelegate.swift b/ios/MullvadVPN/AppDelegate.swift index 2ee783dad0..d54ac731fc 100644 --- a/ios/MullvadVPN/AppDelegate.swift +++ b/ios/MullvadVPN/AppDelegate.swift @@ -21,9 +21,20 @@ class AppDelegate: UIResponder, UIApplicationDelegate { let simulatorTunnelProvider = SimulatorTunnelProviderHost() #endif + #if DEBUG + private let packetTunnelLogForwarder = LogStreamer<UTF8>(fileURLs: [ApplicationConfiguration.packetTunnelLogFileURL!]) + #endif + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { initLoggingSystem(bundleIdentifier: Bundle.main.bundleIdentifier!) + #if DEBUG + let stdoutStream = TextFileOutputStream.standardOutputStream() + packetTunnelLogForwarder.start { (str) in + stdoutStream.write("\(str)\n") + } + #endif + #if targetEnvironment(simulator) SimulatorTunnelProvider.shared.delegate = simulatorTunnelProvider #endif diff --git a/ios/MullvadVPN/ApplicationConfiguration.swift b/ios/MullvadVPN/ApplicationConfiguration.swift index 8dc5063fcb..1052df9851 100644 --- a/ios/MullvadVPN/ApplicationConfiguration.swift +++ b/ios/MullvadVPN/ApplicationConfiguration.swift @@ -16,16 +16,23 @@ class ApplicationConfiguration { /// The application identifier for the PacketTunnel extension static let packetTunnelExtensionIdentifier = "net.mullvad.MullvadVPN.PacketTunnel" - /// The application log files - static var logFileURLs: [URL] { - let containerURL = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: Self.securityGroupIdentifier) - let fileNames = ["net.mullvad.MullvadVPN", "net.mullvad.MullvadVPN.PacketTunnel"] + /// Container URL for security group + static var containerURL: URL? { + return FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: Self.securityGroupIdentifier) + } + + /// The main application log file located in a shared container + static var mainApplicationLogFileURL: URL? { + return Self.containerURL?.appendingPathComponent("Logs/net.mullvad.MullvadVPN.log", isDirectory: false) + } - return fileNames.compactMap { (fileName) -> URL? in - return containerURL? - .appendingPathComponent("Logs", isDirectory: true) - .appendingPathComponent(fileName, isDirectory: false) - .appendingPathExtension("log") - } + /// The packet tunnel log file located in a shared container + static var packetTunnelLogFileURL: URL? { + return Self.containerURL?.appendingPathComponent("Logs/net.mullvad.MullvadVPN.PacketTunnel.log", isDirectory: false) + } + + /// All log files located in a shared container + static var logFileURLs: [URL] { + return [mainApplicationLogFileURL, packetTunnelLogFileURL].compactMap { $0 } } } |
