mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-21 20:45:51 +03:00
Add function to File Provider Logger extension to create debug logs file
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
parent
0ddd22ddbb
commit
1dcfee4087
1 changed files with 20 additions and 0 deletions
|
@ -48,4 +48,24 @@ extension Logger {
|
||||||
return nil
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue