mirror of
https://github.com/twonlyapp/twonly-app.git
synced 2026-01-15 10:38:41 +00:00
fix logging
This commit is contained in:
parent
4484c99fc7
commit
0116e8407a
6 changed files with 29 additions and 16 deletions
|
|
@ -54,6 +54,8 @@ void main() async {
|
||||||
|
|
||||||
await initFileDownloader();
|
await initFileDownloader();
|
||||||
|
|
||||||
|
cleanLogFile();
|
||||||
|
|
||||||
runApp(
|
runApp(
|
||||||
MultiProvider(
|
MultiProvider(
|
||||||
providers: [
|
providers: [
|
||||||
|
|
|
||||||
|
|
@ -155,5 +155,12 @@ class TwonlyDatabase extends _$TwonlyDatabase {
|
||||||
);
|
);
|
||||||
await delete(signalContactPreKeys).go();
|
await delete(signalContactPreKeys).go();
|
||||||
await delete(signalContactSignedPreKeys).go();
|
await delete(signalContactSignedPreKeys).go();
|
||||||
|
await (delete(signalPreKeyStores)
|
||||||
|
..where((t) => (t.createdAt.isSmallerThanValue(
|
||||||
|
DateTime.now().subtract(
|
||||||
|
Duration(days: 25),
|
||||||
|
),
|
||||||
|
))))
|
||||||
|
.go();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -97,8 +97,8 @@ Future performTwonlySafeBackup({bool force = false}) async {
|
||||||
await backupDatabaseFile.delete();
|
await backupDatabaseFile.delete();
|
||||||
await backupDatabaseFileCleaned.delete();
|
await backupDatabaseFileCleaned.delete();
|
||||||
|
|
||||||
Log.info("twonlyDatabaseBytes = ${twonlyDatabaseBytes.lengthInBytes}");
|
Log.info("twonlyDatabaseLength = ${twonlyDatabaseBytes.lengthInBytes}");
|
||||||
Log.info("secureStorageBytes = ${jsonEncode(secureStorageBackup)}");
|
Log.info("secureStorageLength = ${jsonEncode(secureStorageBackup).length}");
|
||||||
|
|
||||||
final backupProto = TwonlySafeBackupContent(
|
final backupProto = TwonlySafeBackupContent(
|
||||||
secureStorageJson: jsonEncode(secureStorageBackup),
|
secureStorageJson: jsonEncode(secureStorageBackup),
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,13 @@ Future<String> loadLogFile() async {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future cleanLogFile() async {
|
||||||
|
final str = await loadLogFile();
|
||||||
|
if (str.contains("secureStorageBytes")) {
|
||||||
|
deleteLogFile();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> _writeLogToFile(LogRecord record) async {
|
Future<void> _writeLogToFile(LogRecord record) async {
|
||||||
final directory = await getApplicationSupportDirectory();
|
final directory = await getApplicationSupportDirectory();
|
||||||
final logFile = File('${directory.path}/app.log');
|
final logFile = File('${directory.path}/app.log');
|
||||||
|
|
@ -57,6 +64,17 @@ Future<void> _writeLogToFile(LogRecord record) async {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<bool> deleteLogFile() async {
|
||||||
|
final directory = await getApplicationSupportDirectory();
|
||||||
|
final logFile = File('${directory.path}/app.log');
|
||||||
|
|
||||||
|
if (await logFile.exists()) {
|
||||||
|
await logFile.delete();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
String _getCallerSourceCodeFilename() {
|
String _getCallerSourceCodeFilename() {
|
||||||
StackTrace stackTrace = StackTrace.current;
|
StackTrace stackTrace = StackTrace.current;
|
||||||
String stackTraceString = stackTrace.toString();
|
String stackTraceString = stackTrace.toString();
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:io';
|
|
||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
import 'package:drift/drift.dart';
|
import 'package:drift/drift.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
|
|
@ -9,7 +8,6 @@ import 'package:flutter_image_compress/flutter_image_compress.dart';
|
||||||
import 'package:gal/gal.dart';
|
import 'package:gal/gal.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
import 'package:local_auth/local_auth.dart';
|
import 'package:local_auth/local_auth.dart';
|
||||||
import 'package:path_provider/path_provider.dart';
|
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:twonly/globals.dart';
|
import 'package:twonly/globals.dart';
|
||||||
import 'package:twonly/src/database/tables/messages_table.dart';
|
import 'package:twonly/src/database/tables/messages_table.dart';
|
||||||
|
|
@ -26,17 +24,6 @@ extension ShortCutsExtension on BuildContext {
|
||||||
ColorScheme get color => Theme.of(this).colorScheme;
|
ColorScheme get color => Theme.of(this).colorScheme;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> deleteLogFile() async {
|
|
||||||
final directory = await getApplicationSupportDirectory();
|
|
||||||
final logFile = File('${directory.path}/app.log');
|
|
||||||
|
|
||||||
if (await logFile.exists()) {
|
|
||||||
await logFile.delete();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<String?> saveImageToGallery(Uint8List imageBytes) async {
|
Future<String?> saveImageToGallery(Uint8List imageBytes) async {
|
||||||
final hasAccess = await Gal.hasAccess();
|
final hasAccess = await Gal.hasAccess();
|
||||||
if (!hasAccess) {
|
if (!hasAccess) {
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ import 'package:path_provider/path_provider.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:share_plus/share_plus.dart';
|
import 'package:share_plus/share_plus.dart';
|
||||||
import 'package:twonly/src/utils/log.dart';
|
import 'package:twonly/src/utils/log.dart';
|
||||||
import 'package:twonly/src/utils/misc.dart';
|
|
||||||
|
|
||||||
class DiagnosticsView extends StatefulWidget {
|
class DiagnosticsView extends StatefulWidget {
|
||||||
const DiagnosticsView({super.key});
|
const DiagnosticsView({super.key});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue