feat: write installation log to temp directory

Installer now writes a detailed log to %TEMP%/edgeai-install.log
(or /tmp/edgeai-install.log on macOS/Linux) with OK/FAIL status for
each step. Log path is shown on completion and in error messages.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
jim800121chen 2026-03-09 18:35:57 +08:00
parent 67242de577
commit ecabffc890

View File

@ -13,6 +13,7 @@ import (
"path/filepath"
"runtime"
"strings"
"time"
wailsRuntime "github.com/wailsapp/wails/v2/pkg/runtime"
)
@ -199,6 +200,25 @@ func (inst *Installer) StartInstall(config InstallConfig) error {
}
func (inst *Installer) runInstall(config InstallConfig) {
// Create install log file
logPath := filepath.Join(os.TempDir(), "edgeai-install.log")
logFile, _ := os.Create(logPath)
if logFile != nil {
defer logFile.Close()
}
logMsg := func(format string, args ...interface{}) {
msg := fmt.Sprintf(format, args...)
if logFile != nil {
fmt.Fprintln(logFile, msg)
}
}
logMsg("=== Edge AI Platform Installation Log ===")
logMsg("Time: %s", time.Now().Format(time.RFC3339))
logMsg("OS: %s/%s", runtime.GOOS, runtime.GOARCH)
logMsg("Install dir: %s", config.InstallDir)
logMsg("")
steps := []struct {
name string
percent float64
@ -225,13 +245,16 @@ func (inst *Installer) runInstall(config InstallConfig) {
})
if err := step.fn(config); err != nil {
logMsg("[FAIL] %s: %s", step.name, err)
if step.critical {
inst.emitProgress(ProgressEvent{
Step: step.name,
Message: fmt.Sprintf("Error: %s — %s", step.name, err),
Message: fmt.Sprintf("Error: %s — %s (see log: %s)", step.name, err, logPath),
Percent: step.percent,
IsError: true,
})
logMsg("")
logMsg("Installation ABORTED.")
return // abort installation
}
inst.emitProgress(ProgressEvent{
@ -240,12 +263,17 @@ func (inst *Installer) runInstall(config InstallConfig) {
Percent: step.percent,
IsError: true,
})
} else {
logMsg("[ OK ] %s", step.name)
}
}
logMsg("")
logMsg("Installation COMPLETE.")
inst.emitProgress(ProgressEvent{
Step: "complete",
Message: "Installation complete!",
Message: fmt.Sprintf("Installation complete! Log: %s", logPath),
Percent: 100,
IsComplete: true,
})