Skip to content

Commit a2b0e89

Browse files
fix(v3/webview2): use log instead of fmt for error and stack trace output (#5453)
On Windows, especially in production applications started outside of a terminal, fmt.Println / fmt.Printf output is often not visible because there is no attached console, so error messages and stack traces from the WebView2 global error handler are lost. Routing them through the log package ensures they reach the standard logger destination. Ports wailsapp/go-webview2#35 to the vendored webview2 package. Co-authored-by: Andrey Pshenkin <andrey.pshenkin@gmail.com>
1 parent b3719f5 commit a2b0e89

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

‎v3/UNRELEASED_CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ After processing, the content will be moved to the main changelog and this file
2525
## Fixed
2626
<!-- Bug fixes -->
2727
- Fix `concurrent map read and map write` runtime fatal in `linuxSystemTray` when the tray menu is updated while the panel reads it.
28+
- Use `log` instead of `fmt` for WebView2 error and stack trace output so messages aren't lost when the app runs without an attached console on Windows.
2829

2930
## Deprecated
3031
<!-- Soon-to-be removed features -->

‎webview2/pkg/edge/chromium.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ func globalErrorHandler(err error) {
2828
return
2929
}
3030

31-
fmt.Printf("[WebView2 Error] %v\n", err)
31+
log.Printf("[WebView2 Error] %v\n", err)
3232

3333
stackBuf := make([]uintptr, 64)
3434
stackSize := runtime.Callers(2, stackBuf)
3535
frames := runtime.CallersFrames(stackBuf[:stackSize])
3636

37-
fmt.Println("\nStack trace:")
37+
log.Printf("\nStack trace:")
3838
stackIndex := 1
3939
for {
4040
frame, more := frames.Next()

0 commit comments

Comments
 (0)