Log log file deletions

This commit is contained in:
vishnukvmd 2021-11-24 12:48:15 +05:30
parent 81c72488d2
commit 27510a2b97

View file

@ -187,7 +187,8 @@ class SuperLogging {
$.info("setting sentry user ID to: $userID");
}
static Future<void> _sendErrorToSentry(Object? error, StackTrace? stack) async {
static Future<void> _sendErrorToSentry(
Object? error, StackTrace? stack) async {
try {
await Sentry.captureException(
error,
@ -315,11 +316,14 @@ class SuperLogging {
// sort files based on ascending order of date (older first)
files.sort((a, b) => dates[a]!.compareTo(dates[b]!));
var extra = files.length - config.maxLogFiles;
var toDelete = files.sublist(0, extra);
final extra = files.length - config.maxLogFiles;
final toDelete = files.sublist(0, extra);
for (var file in toDelete) {
for (final file in toDelete) {
try {
$.fine(
"deleting log file ${file.path}",
);
await file.delete();
} catch (ignore) {}
}