fix(launcher): show log init errors in GUI mode

When the launcher fails to initialize the log file in GUI mode (non-console),
the error message was being written to stderr which is not visible to users.

This fix re-enables console logging before logging the error, ensuring that
users can see the error message even in GUI mode.

Fixes #1734
This commit is contained in:
曾文锋0668000834 2026-03-18 17:25:41 +08:00
parent a1e8ee56f0
commit 93e027a022

View file

@ -81,7 +81,10 @@ func main() {
logPath := filepath.Join(picoHome, "logs", "web.log") logPath := filepath.Join(picoHome, "logs", "web.log")
if err := logger.EnableFileLogging(logPath); err != nil { if err := logger.EnableFileLogging(logPath); err != nil {
fmt.Fprintf(os.Stderr, "Failed to initialize logger: %v\n", err) // Re-enable console logging so the error is visible in GUI mode
logger.SetConsoleLevel(logger.INFO)
logger.Errorf("Failed to initialize log file at %s: %v", logPath, err)
logger.Error("Please check that the logs directory is writable")
os.Exit(1) os.Exit(1)
} }
defer logger.DisableFileLogging() defer logger.DisableFileLogging()