refactor(main): use structured logger instead of fmt for errors
- replaced fmt.Fprintf/Printf with log.Error for post-logger errors - cleanup, phase registration, and installer errors now use slog - kept fmt only for pre-logger messages (version, logger creation failure)
- commit
- 10025b28f2deb1a72393edccc106a6f337d2be12
- author
- bnema · · 2025-10-26 11:26 UTC
- parent
- 7d997b9
- signature
- unsigned
1 file · +3 -3
M cmd/archup-installer/main.go +3 -3
| @@ -42,7 +42,7 @@ func main() { | |||
| 42 | 42 | // Handle --cleanup flag | |
| 43 | 43 | if *doCleanup { | |
| 44 | 44 | if err := cleanup.Run(log); err != nil { | |
| 45 | - | fmt.Fprintf(os.Stderr, "Cleanup failed: %v\n", err) | |
| 45 | + | log.Error("Cleanup failed", "error", err) | |
| 46 | 46 | os.Exit(1) | |
| 47 | 47 | } | |
| 48 | 48 | os.Exit(0) | |
| @@ -73,7 +73,7 @@ func main() { | |||
| 73 | 73 | ||
| 74 | 74 | for _, phase := range phasesToRegister { | |
| 75 | 75 | if err := orchestrator.RegisterPhase(phase); err != nil { | |
| 76 | - | fmt.Fprintf(os.Stderr, "Failed to register phase: %v\n", err) | |
| 76 | + | log.Error("Failed to register phase", "error", err) | |
| 77 | 77 | os.Exit(1) | |
| 78 | 78 | } | |
| 79 | 79 | } | |
| @@ -84,7 +84,7 @@ func main() { | |||
| 84 | 84 | // Run Bubbletea app | |
| 85 | 85 | p := tea.NewProgram(model, tea.WithAltScreen()) | |
| 86 | 86 | if _, err := p.Run(); err != nil { | |
| 87 | - | fmt.Printf("Error running installer: %v\n", err) | |
| 87 | + | log.Error("Error running installer", "error", err) | |
| 88 | 88 | os.Exit(1) | |
| 89 | 89 | } | |
| 90 | 90 | } | |
| @@ -42,7 +42,7 @@ func main() { | |||||
| 42 | // Handle --cleanup flag | 42 | // Handle --cleanup flag | ||
| 43 | if *doCleanup { | 43 | if *doCleanup { | ||
| 44 | if err := cleanup.Run(log); err != nil { | 44 | if err := cleanup.Run(log); err != nil { | ||
| 45 | - | fmt.Fprintf(os.Stderr, "Cleanup failed: %v\n", err) | 45 | + | log.Error("Cleanup failed", "error", err) |
| 46 | os.Exit(1) | 46 | os.Exit(1) | ||
| 47 | } | 47 | } | ||
| 48 | os.Exit(0) | 48 | os.Exit(0) | ||
| @@ -73,7 +73,7 @@ func main() { | |||||
| 73 | 73 | ||||
| 74 | for _, phase := range phasesToRegister { | 74 | for _, phase := range phasesToRegister { | ||
| 75 | if err := orchestrator.RegisterPhase(phase); err != nil { | 75 | if err := orchestrator.RegisterPhase(phase); err != nil { | ||
| 76 | - | fmt.Fprintf(os.Stderr, "Failed to register phase: %v\n", err) | 76 | + | log.Error("Failed to register phase", "error", err) |
| 77 | os.Exit(1) | 77 | os.Exit(1) | ||
| 78 | } | 78 | } | ||
| 79 | } | 79 | } | ||
| @@ -84,7 +84,7 @@ func main() { | |||||
| 84 | // Run Bubbletea app | 84 | // Run Bubbletea app | ||
| 85 | p := tea.NewProgram(model, tea.WithAltScreen()) | 85 | p := tea.NewProgram(model, tea.WithAltScreen()) | ||
| 86 | if _, err := p.Run(); err != nil { | 86 | if _, err := p.Run(); err != nil { | ||
| 87 | - | fmt.Printf("Error running installer: %v\n", err) | 87 | + | log.Error("Error running installer", "error", err) |
| 88 | os.Exit(1) | 88 | os.Exit(1) | ||
| 89 | } | 89 | } | ||
| 90 | } | 90 | } | ||