wails/v3/pkg/application/application_debug.go
Lea Anthony c4b614cb10
fix: use structured logging for debug/info methods (#4767)
* fix: use structured logging for debug/info methods

The debug() and info() methods were using fmt.Sprintf() which expects
printf-style format directives, but callers were using slog-style
key-value pairs. Changed to pass args directly to Logger.Debug/Info
which properly handles structured logging.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* docs: add changelog entries for build fixes

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* chore: remove temporary debug print statements from mobile merge

Remove emoji debug logs (🔴, 🟢, 🟠, 🔵, 🔥) that were accidentally left in
from the iOS/Android mobile platform support merge. These were development
debugging statements that should not have been included in the final code.

Files cleaned:
- application.go
- application_debug.go
- init_android.go
- init_ios.go
- mainthread_android.go
- mainthread_ios.go
- webview_window.go
- webview_window_ios.go

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* docs: add changelog entries for debug cleanup and breaking change

- Add breaking change note: production builds are now default
- Add entry for debug print statement removal

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix: convert remaining printf-style debug calls to slog-style

Convert three debug() calls that were still using printf-style format
strings to slog-style structured logging (key-value pairs):

- systemtray_windows.go: ShellNotifyIcon show/hide failures
- application_darwin.go: window lookup failure

This addresses CodeRabbit review feedback and ensures consistency
with the refactored debug() method.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix: convert all printf-style info() calls to slog-style

Convert remaining info() calls that were using printf-style format
strings to slog-style structured logging (key-value pairs):

- application_ios.go: iOS log messages and HandleJSMessage calls
- webview_window_windows.go: WM_SYSKEYDOWN logging
- application.go: handleWindowMessage and handleWebViewRequest logging

Also removed debug fmt.Printf statements from handleWebViewRequest.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix: add build tag to main.m to prevent Go from compiling it on non-iOS platforms

Go's toolchain tries to process .m (Objective-C) files when they're in a
directory with Go files. Adding a //go:build ios tag tells Go to only
process this file when building for iOS, matching how darwin .m files
handle this (e.g., //go:build darwin && !ios).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* chore: remove orphaned wails-mimetype-migration submodule reference

The iOS merge added a submodule reference without a corresponding
.gitmodules file, causing Cloudflare and other CI systems to fail
with "No url found for submodule path" errors.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix: auto-disable DMA-BUF renderer on Wayland with NVIDIA to prevent crashes

WebKitGTK has a known issue with the DMA-BUF renderer on NVIDIA proprietary
drivers running Wayland, causing "Error 71 (Protocol error)" crashes.

This fix automatically detects NVIDIA GPUs (via /sys/module/nvidia) and sets
WEBKIT_DISABLE_DMABUF_RENDERER=1 when running on Wayland.

Also removes leftover debug print statements from mobile platform merge.

See: https://bugs.webkit.org/show_bug.cgi?id=262607

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat: add NVIDIA driver info to wails3 doctor on Linux

Shows NVIDIA driver version and srcversion in doctor output to help
diagnose Wayland/NVIDIA compatibility issues.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-12 09:03:11 +11:00

71 lines
1.7 KiB
Go

//go:build !production
package application
import (
"github.com/go-git/go-git/v5"
"github.com/samber/lo"
"github.com/wailsapp/wails/v3/internal/version"
"path/filepath"
"runtime/debug"
)
// BuildSettings contains the build settings for the application
var BuildSettings map[string]string
// BuildInfo contains the build info for the application
var BuildInfo *debug.BuildInfo
func init() {
var ok bool
BuildInfo, ok = debug.ReadBuildInfo()
if !ok {
return
}
BuildSettings = lo.Associate(BuildInfo.Settings, func(setting debug.BuildSetting) (string, string) {
return setting.Key, setting.Value
})
}
// We use this to patch the application to production mode.
func newApplication(options Options) *App {
result := &App{
isDebugMode: true,
options: options,
}
result.init()
return result
}
func (a *App) logStartup() {
var args []any
// BuildInfo is nil when build with garble
if BuildInfo == nil {
return
}
wailsPackage, _ := lo.Find(BuildInfo.Deps, func(dep *debug.Module) bool {
return dep.Path == "github.com/wailsapp/wails/v3"
})
wailsVersion := version.String()
if wailsPackage != nil && wailsPackage.Replace != nil {
wailsVersion = "(local) => " + filepath.ToSlash(wailsPackage.Replace.Path)
// Get the latest commit hash
repo, err := git.PlainOpen(filepath.Join(wailsPackage.Replace.Path, ".."))
if err == nil {
head, err := repo.Head()
if err == nil {
wailsVersion += " (" + head.Hash().String()[:8] + ")"
}
}
}
args = append(args, "Wails", wailsVersion)
args = append(args, "Compiler", BuildInfo.GoVersion)
for key, value := range BuildSettings {
args = append(args, key, value)
}
a.info("Build Info:", args...)
}