summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--ios/MullvadVPN/AppDelegate.swift11
-rw-r--r--ios/MullvadVPN/ApplicationConfiguration.swift27
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 }
}
}