purgeOldLogs method

Future<void> purgeOldLogs()

Deletes all logs older than 2 days from persistent storage.

The logs are deleted asynchronously in a separate isolate to avoid blocking the main isolate.

This is useful for limiting the amount of disk space used by the log files.

Implementation

Future<void> purgeOldLogs() async {
  final dir = await getApplicationSupportDirectory();
  final path = dir.path;
  await Isolate.run(() => IsolateLogWriter.purgeOldLogs(path, 2));
}