fix: Export patcher logs as a file instead of text

This commit is contained in:
Alberto Ponces 2022-09-14 10:40:45 +01:00
parent 698f1ac383
commit 855b8373e4
3 changed files with 15 additions and 4 deletions

View File

@ -194,7 +194,18 @@ class PatcherAPI {
} }
} }
void shareLog(String logs) { Future<void> sharePatcherLog(String logs) async {
ShareExtend.share(logs, 'text'); Directory appCache = await getTemporaryDirectory();
Directory logDir = Directory('${appCache.path}/logs');
logDir.createSync();
String dateTime = DateTime.now()
.toIso8601String()
.replaceAll('-', '')
.replaceAll(':', '')
.replaceAll('T', '')
.replaceAll('.', '');
File log = File('${logDir.path}/revanced-manager_patcher_$dateTime.log');
log.writeAsStringSync(logs);
ShareExtend.share(log.path, 'file');
} }
} }

View File

@ -151,7 +151,7 @@ class InstallerViewModel extends BaseViewModel {
} }
void shareLog() { void shareLog() {
_patcherAPI.shareLog(logs); _patcherAPI.sharePatcherLog(logs);
} }
Future<void> cleanPatcher() async { Future<void> cleanPatcher() async {

View File

@ -235,7 +235,7 @@ class SettingsViewModel extends BaseViewModel {
.replaceAll(':', '') .replaceAll(':', '')
.replaceAll('T', '') .replaceAll('T', '')
.replaceAll('.', ''); .replaceAll('.', '');
File logcat = File('${logDir.path}/revanced-manager_$dateTime.log'); File logcat = File('${logDir.path}/revanced-manager_logcat_$dateTime.log');
String logs = await Logcat.execute(); String logs = await Logcat.execute();
logcat.writeAsStringSync(logs); logcat.writeAsStringSync(logs);
ShareExtend.share(logcat.path, 'file'); ShareExtend.share(logcat.path, 'file');