From 679d63294dad8abdb68b9bcd270746912ec4e7cf Mon Sep 17 00:00:00 2001 From: Roopesh Chander Date: Thu, 29 Nov 2018 15:46:21 +0530 Subject: NE: Write log to file Signed-off-by: Roopesh Chander --- WireGuard/Shared/FileManager+Extension.swift | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 WireGuard/Shared/FileManager+Extension.swift (limited to 'WireGuard/Shared/FileManager+Extension.swift') diff --git a/WireGuard/Shared/FileManager+Extension.swift b/WireGuard/Shared/FileManager+Extension.swift new file mode 100644 index 0000000..7b25ffb --- /dev/null +++ b/WireGuard/Shared/FileManager+Extension.swift @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: MIT +// Copyright © 2018 WireGuard LLC. All Rights Reserved. + +import Foundation +import os.log + +extension FileManager { + static var networkExtensionLogFileURL: URL? { + guard let appGroupId = Bundle.main.object(forInfoDictionaryKey: "com.wireguard.ios.app_group_id") as? String else { + os_log("Can't obtain app group id from bundle", log: OSLog.default, type: .error) + return nil + } + guard let sharedFolderURL = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: appGroupId) else { + os_log("Can't obtain shared folder URL", log: OSLog.default, type: .error) + return nil + } + return sharedFolderURL.appendingPathComponent("lastActivatedTunnelLog.txt") + } +} -- cgit v1.2.3-59-g8ed1b