From 7ff5127ee87ce4b333ccf47552a538adf21ebd49 Mon Sep 17 00:00:00 2001 From: qianlifeng Date: Wed, 22 Jan 2025 20:52:11 +0800 Subject: [PATCH] Refactor logging setup and improve error handling in crash output; adjust widget structure in Flutter UI for better readability --- wox.core/util/log.go | 9 ++++++--- wox.ui.flutter/wox/lib/components/wox_preview_view.dart | 6 +++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/wox.core/util/log.go b/wox.core/util/log.go index 13ecf2daf..e3630e71a 100644 --- a/wox.core/util/log.go +++ b/wox.core/util/log.go @@ -28,19 +28,22 @@ func GetLogger() *Log { logOnce.Do(func() { logFolder := GetLocation().GetLogDirectory() logInstance = CreateLogger(logFolder) - setCrashOutput() + setCrashOutput(logInstance) }) return logInstance } -func setCrashOutput() { +func setCrashOutput(logInstance *Log) { logFile := path.Join(GetLocation().GetLogDirectory(), "crash.log") crashFile, err := os.Create(logFile) if err != nil { panic(err) } - debug.SetCrashOutput(crashFile, debug.CrashOptions{}) + setCrashOutputErr := debug.SetCrashOutput(crashFile, debug.CrashOptions{}) + if setCrashOutputErr != nil { + logInstance.Error(context.Background(), fmt.Sprintf("failed to set crash output: %s", setCrashOutputErr.Error())) + } } func CreateLogger(logFolder string) *Log { diff --git a/wox.ui.flutter/wox/lib/components/wox_preview_view.dart b/wox.ui.flutter/wox/lib/components/wox_preview_view.dart index 2be6eadef..434f15f85 100644 --- a/wox.ui.flutter/wox/lib/components/wox_preview_view.dart +++ b/wox.ui.flutter/wox/lib/components/wox_preview_view.dart @@ -78,9 +78,9 @@ class _WoxPreviewViewState extends State { } Widget buildText(String txtData) { - return Scrollbar( - child: SingleChildScrollView( - controller: scrollController, + return SingleChildScrollView( + controller: scrollController, + child: Scrollbar( child: SelectableText( txtData, style: TextStyle(color: fromCssColor(widget.woxTheme.previewFontColor)),