Fix logging

This commit is contained in:
problematicconsumer
2023-08-24 22:19:22 +03:30
parent 4edd2e1f8a
commit 49519b7fd7
3 changed files with 25 additions and 25 deletions

View File

@@ -18,7 +18,7 @@ import 'package:share_plus/share_plus.dart';
import 'package:tint/tint.dart';
import 'package:url_launcher/url_launcher.dart';
class LogsPage extends HookConsumerWidget {
class LogsPage extends HookConsumerWidget with PresLogger {
const LogsPage({super.key});
@override
@@ -28,39 +28,26 @@ class LogsPage extends HookConsumerWidget {
final notifier = ref.watch(logsNotifierProvider.notifier);
final debug = ref.watch(debugModeProvider);
final filesEditor = ref.watch(filesEditorServiceProvider);
final List<PopupMenuEntry> popupButtons = debug || PlatformUtils.isDesktop
? [
PopupMenuItem(
child: Text(t.logs.shareCoreLogs.sentenceCase),
onTap: () async {
if (Platform.isWindows || Platform.isLinux) {
await launchUrl(
ref.read(filesEditorServiceProvider).logsDir.uri,
);
} else {
final file = XFile(
ref.read(filesEditorServiceProvider).coreLogsPath,
mimeType: "text/plain",
);
await Share.shareXFiles([file]);
}
await shareFileOrOpenDir(
filesEditor.coreLogsPath,
filesEditor.logsDir.uri,
);
},
),
PopupMenuItem(
child: Text(t.logs.shareAppLogs.sentenceCase),
onTap: () async {
if (Platform.isWindows || Platform.isLinux) {
await launchUrl(
ref.read(filesEditorServiceProvider).logsDir.uri,
);
} else {
final file = XFile(
ref.read(filesEditorServiceProvider).appLogsPath,
mimeType: "text/plain",
);
await Share.shareXFiles([file]);
}
await shareFileOrOpenDir(
filesEditor.appLogsPath,
filesEditor.logsDir.uri,
);
},
),
]
@@ -177,4 +164,17 @@ class LogsPage extends HookConsumerWidget {
return const Scaffold();
}
}
Future<void> shareFileOrOpenDir(String path, Uri dir) async {
try {
if (Platform.isWindows || Platform.isLinux) {
await launchUrl(dir);
} else {
final file = XFile(path, mimeType: "text/plain");
await Share.shareXFiles([file]);
}
} catch (err, stackTrace) {
loggy.warning("error sharing log file", err, stackTrace);
}
}
}

View File

@@ -40,7 +40,7 @@ class ProxiesDelayNotifier extends _$ProxiesDelayNotifier with AppLogger {
final testUrl = ref.read(connectionTestUrlProvider);
final concurrent = ref.read(concurrentTestCountProvider);
loggy.debug(
loggy.info(
'testing delay for [${proxies.length}] proxies with [$testUrl], [$concurrent] at a time',
);