aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoopesh Chander <roop@roopc.net>2018-12-04 13:50:43 +0530
committerRoopesh Chander <roop@roopc.net>2018-12-04 14:12:53 +0530
commit4e386e85e43d3eda01cbd303ee188ad1527db922 (patch)
tree20ef09881d94f9f3f146317c553b71d4b7b8db5b
parentRefactor out VPN-handling stuff from tunnels list VC to the main VC (diff)
downloadwireguard-apple-4e386e85e43d3eda01cbd303ee188ad1527db922.tar.xz
wireguard-apple-4e386e85e43d3eda01cbd303ee188ad1527db922.zip
Settings: Add timestamp to exported log
And remove the exported log afterwards. Signed-off-by: Roopesh Chander <roop@roopc.net>
-rw-r--r--WireGuard/WireGuard/UI/iOS/SettingsTableViewController.swift9
1 files changed, 8 insertions, 1 deletions
diff --git a/WireGuard/WireGuard/UI/iOS/SettingsTableViewController.swift b/WireGuard/WireGuard/UI/iOS/SettingsTableViewController.swift
index 994eb22..6f8410e 100644
--- a/WireGuard/WireGuard/UI/iOS/SettingsTableViewController.swift
+++ b/WireGuard/WireGuard/UI/iOS/SettingsTableViewController.swift
@@ -96,7 +96,10 @@ class SettingsTableViewController: UITableViewController {
return
}
- let destinationURL = destinationDir.appendingPathComponent("WireGuard_iOS_log.txt")
+ let dateFormatter = ISO8601DateFormatter()
+ dateFormatter.formatOptions = [.withFullDate, .withTime, .withTimeZone] // Avoid ':' in the filename
+ let timeStampString = dateFormatter.string(from: Date())
+ let destinationURL = destinationDir.appendingPathComponent("WireGuard_iOS_log_\(timeStampString).txt")
if (FileManager.default.fileExists(atPath: destinationURL.path)) {
do {
@@ -126,6 +129,10 @@ class SettingsTableViewController: UITableViewController {
// popoverPresentationController shall be non-nil on the iPad
activityVC.popoverPresentationController?.sourceView = sourceView
activityVC.popoverPresentationController?.sourceRect = sourceView.bounds
+ activityVC.completionWithItemsHandler = { (_, _, _, _) in
+ // Remove the exported log file after the activity has completed
+ try? FileManager.default.removeItem(at: destinationURL)
+ }
self.present(activityVC, animated: true)
}