diff options
| author | Jon Petersson <jon.petersson@kvadrat.se> | 2024-04-08 13:11:54 +0200 |
|---|---|---|
| committer | Bug Magnet <marco.nikic@mullvad.net> | 2024-04-17 09:47:26 +0200 |
| commit | 293be10e3404ae8b858c85b3bb8ca30b56b9e469 (patch) | |
| tree | 43126055790a2e873501f8a785bf2df9480811f3 /ios/Shared | |
| parent | 446baab81ddd11f6abeae295283103925dfb6f14 (diff) | |
| download | mullvadvpn-293be10e3404ae8b858c85b3bb8ca30b56b9e469.tar.xz mullvadvpn-293be10e3404ae8b858c85b3bb8ca30b56b9e469.zip | |
Change log rotation to a quota based system
Diffstat (limited to 'ios/Shared')
| -rw-r--r-- | ios/Shared/ApplicationConfiguration.swift | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/ios/Shared/ApplicationConfiguration.swift b/ios/Shared/ApplicationConfiguration.swift index 426067e1dd..9acea1b971 100644 --- a/ios/Shared/ApplicationConfiguration.swift +++ b/ios/Shared/ApplicationConfiguration.swift @@ -21,9 +21,25 @@ enum ApplicationConfiguration { FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: securityGroupIdentifier)! } - /// Returns URL for log file associated with application target and located within shared container. - static func logFileURL(for target: ApplicationTarget) -> URL { - containerURL.appendingPathComponent("\(target.bundleIdentifier).log", isDirectory: false) + /// Returns URL for new log file associated with application target and located within shared container. + static func newLogFileURL(for target: ApplicationTarget) -> URL { + containerURL.appendingPathComponent( + "\(target.bundleIdentifier)_\(Date().logFormatFilename()).log", + isDirectory: false + ) + } + + /// Returns URLs for log files associated with application target and located within shared container. + static func logFileURLs(for target: ApplicationTarget) -> [URL] { + let containerUrl = containerURL + + return (try? FileManager.default.contentsOfDirectory(atPath: containerURL.relativePath))?.compactMap { file in + if file.split(separator: ".").last == "log" { + containerUrl.appendingPathComponent(file) + } else { + nil + } + }.sorted { $0.relativePath > $1.relativePath } ?? [] } /// Privacy policy URL. |
