Skip to content

Commit

Permalink
Refactor logging setup and improve error handling in crash output; ad…
Browse files Browse the repository at this point in the history
…just widget structure in Flutter UI for better readability
  • Loading branch information
qianlifeng committed Jan 22, 2025
1 parent 34fd0cf commit 7ff5127
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
9 changes: 6 additions & 3 deletions wox.core/util/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions wox.ui.flutter/wox/lib/components/wox_preview_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ class _WoxPreviewViewState extends State<WoxPreviewView> {
}

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)),
Expand Down

0 comments on commit 7ff5127

Please sign in to comment.