Fix logging
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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',
|
||||
);
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ class MobileSingboxService with InfraLogger implements SingboxService {
|
||||
Stream<String> watchLogs(String path) {
|
||||
return _logsChannel.receiveBroadcastStream().map(
|
||||
(event) {
|
||||
loggy.debug("received log: $event");
|
||||
// loggy.debug("received log: $event");
|
||||
return event as String;
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user