mirror of
https://mirror.ghproxy.com/https://github.com/StarCitizenToolBox/app.git
synced 2024-12-23 01:53:41 +08:00
feat: delete logs when inDays > 7
This commit is contained in:
parent
d05aa0d5f8
commit
dd14a34285
@ -19,8 +19,22 @@ void dPrint(src) async {
|
||||
});
|
||||
}
|
||||
|
||||
void setDPrintFile(File file) {
|
||||
_logFile = file;
|
||||
Future<void> initDPrintFile(String applicationSupportDir) async {
|
||||
final now = DateTime.now();
|
||||
final logFile =
|
||||
File("$applicationSupportDir\\logs\\${now.millisecondsSinceEpoch}.log");
|
||||
await logFile.create(recursive: true);
|
||||
_logFile = logFile;
|
||||
final logsDir = Directory("$applicationSupportDir\\logs");
|
||||
await for (final files in logsDir.list()) {
|
||||
if (files is File) {
|
||||
final stat = await files.stat();
|
||||
if (stat.type == FileSystemEntityType.file &&
|
||||
now.difference(await files.lastModified()).inDays > 7) {
|
||||
await files.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File? getDPrintFile() {
|
||||
|
Loading…
Reference in New Issue
Block a user