Skip to content

Commit

Permalink
Add function to File Provider Logger extension to create debug logs file
Browse files Browse the repository at this point in the history
Signed-off-by: Claudio Cambra <[email protected]>
  • Loading branch information
claucambra committed Nov 1, 2023
1 parent e717e5d commit 5927729
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,24 @@ extension Logger {
return nil
}
}

@available(macOSApplicationExtension 12.0, *)
static func createDebugArchive(saveFolderUrl: URL) {
let saveFileUrl = saveFolderUrl.appendingPathComponent("nc-fileprovider-debug.txt")
let saveFilePath = saveFolderUrl.path

guard FileManager.default.createFile(atPath: saveFilePath, contents: nil) else {
Logger.logger.error("Could not create log file")
return
}

guard let logs = Logger.logEntries() else {
Logger.logger.error("Cannot create debug archive without any logs.")
return
}

for logString in logs {
try? logString.write(to: saveFileUrl, atomically: true, encoding: .utf8)
}
}
}

0 comments on commit 5927729

Please sign in to comment.