From 855b8373e44ba2a75efa6bef85aa4bffbb31142a Mon Sep 17 00:00:00 2001 From: Alberto Ponces Date: Wed, 14 Sep 2022 10:40:45 +0100 Subject: [PATCH] fix: Export patcher logs as a file instead of text --- lib/services/patcher_api.dart | 15 +++++++++++++-- lib/ui/views/installer/installer_viewmodel.dart | 2 +- lib/ui/views/settings/settings_viewmodel.dart | 2 +- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/lib/services/patcher_api.dart b/lib/services/patcher_api.dart index f9339301..74f5e1a0 100644 --- a/lib/services/patcher_api.dart +++ b/lib/services/patcher_api.dart @@ -194,7 +194,18 @@ class PatcherAPI { } } - void shareLog(String logs) { - ShareExtend.share(logs, 'text'); + Future sharePatcherLog(String logs) async { + 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'); } } diff --git a/lib/ui/views/installer/installer_viewmodel.dart b/lib/ui/views/installer/installer_viewmodel.dart index 8167dd0a..176502c2 100644 --- a/lib/ui/views/installer/installer_viewmodel.dart +++ b/lib/ui/views/installer/installer_viewmodel.dart @@ -151,7 +151,7 @@ class InstallerViewModel extends BaseViewModel { } void shareLog() { - _patcherAPI.shareLog(logs); + _patcherAPI.sharePatcherLog(logs); } Future cleanPatcher() async { diff --git a/lib/ui/views/settings/settings_viewmodel.dart b/lib/ui/views/settings/settings_viewmodel.dart index b08e728c..d9874a43 100644 --- a/lib/ui/views/settings/settings_viewmodel.dart +++ b/lib/ui/views/settings/settings_viewmodel.dart @@ -235,7 +235,7 @@ class SettingsViewModel extends BaseViewModel { .replaceAll(':', '') .replaceAll('T', '') .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(); logcat.writeAsStringSync(logs); ShareExtend.share(logcat.path, 'file');