summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@mullvad.net>2021-08-25 14:25:01 +0200
committerAndrej Mihajlov <and@mullvad.net>2021-08-30 13:30:28 +0200
commit2dd8c58ae4d9afb22c2a99c9c27ee453cd492d63 (patch)
tree9fcd2bfcbcdfbe52c84623e9748a1d2ba585d381
parent7eaebdb1ce52d602363735d3e9f7f19616bd7f46 (diff)
downloadmullvadvpn-2dd8c58ae4d9afb22c2a99c9c27ee453cd492d63.tar.xz
mullvadvpn-2dd8c58ae4d9afb22c2a99c9c27ee453cd492d63.zip
Add backup log files to problem report
-rw-r--r--ios/MullvadVPN/ConsolidatedApplicationLog.swift46
-rw-r--r--ios/MullvadVPN/ProblemReportViewController.swift2
2 files changed, 29 insertions, 19 deletions
diff --git a/ios/MullvadVPN/ConsolidatedApplicationLog.swift b/ios/MullvadVPN/ConsolidatedApplicationLog.swift
index 1b868caf01..1e52ba10e1 100644
--- a/ios/MullvadVPN/ConsolidatedApplicationLog.swift
+++ b/ios/MullvadVPN/ConsolidatedApplicationLog.swift
@@ -57,27 +57,18 @@ class ConsolidatedApplicationLog: TextOutputStreamable {
}
}
- func addLogFile(fileURL: URL) {
- guard fileURL.isFileURL else {
- addError(message: fileURL.absoluteString, error: Error.invalidLogFileURL(fileURL))
- return
- }
-
- let path = fileURL.path
- let redactedPath = redact(string: path)
-
- switch Self.readFileLossy(path: path, maxBytes: kLogMaxReadBytes) {
- case .success(let lossyString):
- let redactedString = redact(string: lossyString)
- logs.append(LogAttachment(label: redactedPath, content: redactedString))
-
- case .failure(let error):
- addError(message: redactedPath, error: error)
+ func addLogFile(fileURL: URL, includeLogBackup: Bool) {
+ addSingleLogFile(fileURL)
+ if includeLogBackup {
+ let oldLogFileURL = fileURL.deletingPathExtension().appendingPathExtension("old.log")
+ addSingleLogFile(oldLogFileURL)
}
}
- func addLogFiles(fileURLs: [URL]) {
- fileURLs.forEach(self.addLogFile)
+ func addLogFiles(fileURLs: [URL], includeLogBackups: Bool) {
+ for fileURL in fileURLs {
+ addLogFile(fileURL: fileURL, includeBackupLog: includeLogBackups)
+ }
}
func addError<ErrorType: ChainedError>(message: String, error: ErrorType) {
@@ -108,6 +99,25 @@ class ConsolidatedApplicationLog: TextOutputStreamable {
}
}
+ private func addSingleLogFile(_ fileURL: URL) {
+ guard fileURL.isFileURL else {
+ addError(message: fileURL.absoluteString, error: Error.invalidLogFileURL(fileURL))
+ return
+ }
+
+ let path = fileURL.path
+ let redactedPath = redact(string: path)
+
+ switch Self.readFileLossy(path: path, maxBytes: kLogMaxReadBytes) {
+ case .success(let lossyString):
+ let redactedString = redact(string: lossyString)
+ logs.append(LogAttachment(label: redactedPath, content: redactedString))
+
+ case .failure(let error):
+ addError(message: redactedPath, error: error)
+ }
+ }
+
private static func makeMetadata() -> Metadata {
let osVersion = ProcessInfo.processInfo.operatingSystemVersion
let osVersionString = "iOS \(osVersion.majorVersion).\(osVersion.minorVersion).\(osVersion.patchVersion)"
diff --git a/ios/MullvadVPN/ProblemReportViewController.swift b/ios/MullvadVPN/ProblemReportViewController.swift
index 1535d1ec26..cd6ec4a490 100644
--- a/ios/MullvadVPN/ProblemReportViewController.swift
+++ b/ios/MullvadVPN/ProblemReportViewController.swift
@@ -25,7 +25,7 @@ class ProblemReportViewController: UIViewController, UITextFieldDelegate, Condit
redactContainerPathsForSecurityGroupIdentifiers: [securityGroupIdentifier]
)
- report.addLogFiles(fileURLs: ApplicationConfiguration.logFileURLs)
+ report.addLogFiles(fileURLs: ApplicationConfiguration.logFileURLs, includeLogBackup: true)
return report
}()