Improve logging (#2)

Reviewed-on: #2
This commit is contained in:
2025-07-24 15:30:33 +00:00
parent 71f044e6e0
commit bc80ca2c9c
22 changed files with 411 additions and 307 deletions

View File

@@ -1,11 +1,11 @@
package ui
import (
"epochsilicon/pkg/log"
"net/url"
"strings"
"time"
"epochsilicon/pkg/debug"
"epochsilicon/pkg/launcher"
"epochsilicon/pkg/patching"
"epochsilicon/pkg/service"
@@ -27,7 +27,7 @@ func createOptionsComponents() {
prefs, _ := utils.LoadPrefs()
prefs.EnableMetalHud = checked
utils.SavePrefs(prefs)
debug.Printf("Metal HUD enabled: %v", launcher.EnableMetalHud)
log.Debugf("Metal HUD enabled: %v", launcher.EnableMetalHud)
})
metalHudCheckbox.SetChecked(prefs.EnableMetalHud)
launcher.EnableMetalHud = prefs.EnableMetalHud
@@ -37,17 +37,32 @@ func createOptionsComponents() {
prefs, _ := utils.LoadPrefs()
prefs.ShowTerminalNormally = checked
utils.SavePrefs(prefs)
debug.Printf("Show terminal normally: %v", checked)
log.Debugf("Show terminal normally: %v", checked)
})
showTerminalCheckbox.SetChecked(prefs.ShowTerminalNormally)
advancedLoggingCheckbox = widget.NewCheck("Advanced Logging", func(checked bool) {
// Save to preferences
prefs, _ := utils.LoadPrefs()
prefs.AdvancedLogging = checked
utils.SavePrefs(prefs)
log.Debugf("Advanced logging set to %v", checked)
if checked {
log.SetLevelDebug()
} else {
log.SetLevelInfo()
}
})
advancedLoggingCheckbox.SetChecked(prefs.AdvancedLogging)
autoDeleteWdbCheckbox = widget.NewCheck("Auto-delete WDB directory on launch", func(checked bool) {
launcher.AutoDeleteWdb = checked
// Save to preferences
prefs, _ := utils.LoadPrefs()
prefs.AutoDeleteWdb = checked
utils.SavePrefs(prefs)
debug.Printf("Auto-delete WDB enabled: %v", launcher.AutoDeleteWdb)
log.Debugf("Auto-delete WDB enabled: %v", launcher.AutoDeleteWdb)
})
autoDeleteWdbCheckbox.SetChecked(prefs.AutoDeleteWdb)
launcher.AutoDeleteWdb = prefs.AutoDeleteWdb
@@ -69,7 +84,7 @@ func createOptionsComponents() {
prefs, _ := utils.LoadPrefs()
prefs.EnvironmentVariables = text
utils.SavePrefs(prefs)
debug.Printf("Environment variables updated: %v", launcher.CustomEnvVars)
log.Debugf("Environment variables updated: %v", launcher.CustomEnvVars)
}
}
@@ -126,7 +141,7 @@ func createBottomBar(myWindow fyne.Window) fyne.CanvasObject {
githubURL := "https://git.burkey.co/eburk/epochsilicon"
parsedURL, err := url.Parse(githubURL)
if err != nil {
debug.Printf("Error parsing git URL: %v", err)
log.Debugf("Error parsing git URL: %v", err)
return
}
fyne.CurrentApp().OpenURL(parsedURL)
@@ -198,7 +213,7 @@ func createWineRegistryComponents() {
}()
if err := utils.SetOptionAsAltEnabled(true); err != nil {
debug.Printf("Failed to enable Option-as-Alt mapping: %v", err)
log.Debugf("Failed to enable Option-as-Alt mapping: %v", err)
// Update UI on main thread
fyne.Do(func() {
stopPulsingEffect()
@@ -206,7 +221,7 @@ func createWineRegistryComponents() {
})
time.Sleep(2 * time.Second) // Show error briefly
} else {
debug.Printf("Successfully enabled Option-as-Alt mapping")
log.Debugf("Successfully enabled Option-as-Alt mapping")
// Update preferences
prefs, _ := utils.LoadPrefs()
prefs.RemapOptionAsAlt = true
@@ -240,7 +255,7 @@ func createWineRegistryComponents() {
}()
if err := utils.SetOptionAsAltEnabled(false); err != nil {
debug.Printf("Failed to disable Option-as-Alt mapping: %v", err)
log.Debugf("Failed to disable Option-as-Alt mapping: %v", err)
// Update UI on main thread
fyne.Do(func() {
stopPulsingEffect()
@@ -248,7 +263,7 @@ func createWineRegistryComponents() {
})
time.Sleep(2 * time.Second) // Show error briefly
} else {
debug.Printf("Successfully disabled Option-as-Alt mapping")
log.Debugf("Successfully disabled Option-as-Alt mapping")
// Update preferences
prefs, _ := utils.LoadPrefs()
prefs.RemapOptionAsAlt = false

View File

@@ -1,7 +1,7 @@
package ui
import (
"epochsilicon/pkg/debug"
"epochsilicon/pkg/log"
"epochsilicon/pkg/paths"
"fyne.io/fyne/v2"
@@ -34,7 +34,7 @@ func createLogoContainer() fyne.CanvasObject {
// Load the application logo
logoResource, err := fyne.LoadResourceFromPath("Icon.png")
if err != nil {
debug.Printf("Warning: could not load logo: %v", err)
log.Debugf("Warning: could not load logo: %v", err)
}
// Create the logo image with a smaller fixed size since we have a header now

View File

@@ -30,6 +30,7 @@ func showOptionsPopup() {
generalContainer := container.NewVBox(
generalTitle,
widget.NewSeparator(),
advancedLoggingCheckbox,
metalHudCheckbox,
showTerminalCheckbox,
autoDeleteWdbCheckbox,
@@ -222,11 +223,11 @@ func showTroubleshootingPopup() {
troubleshootingCloseButton = widget.NewButton("Close", func() {})
popupContent := container.NewBorder(
nil, // top
nil, // top
container.NewCenter(troubleshootingCloseButton), // bottom
nil, // left
nil, // right
container.NewPadded(scrollContainer), // center
nil, // left
nil, // right
container.NewPadded(scrollContainer), // center
)
windowSize := currentWindow.Content().Size()

View File

@@ -1,7 +1,7 @@
package ui
import (
"epochsilicon/pkg/debug"
"epochsilicon/pkg/log"
"git.burkey.co/eburk/epochcli/pkg/epoch"
"os"
"path/filepath"
@@ -108,13 +108,13 @@ func updateEpochStatus() {
// Check for Epoch-specific files
epochPatchesApplied := false
stats, err := epoch.Update(paths.EpochPath, false, true, true)
if err != nil {
debug.Printf("Failed to get download Epoch patches: %v", err)
}
if stats.Outdated == 0 {
debug.Println("Nothing is outdated")
epochPatchesApplied = true
stats := epoch.Update(paths.EpochPath, false, true, true)
if stats.Error != nil {
log.Error(stats.Error.Error())
} else {
if stats.Outdated == 0 {
epochPatchesApplied = true
}
}
// Check if patched files have the correct size (matches bundled versions)

View File

@@ -1,11 +1,11 @@
package ui
import (
"epochsilicon/pkg/log"
"fmt"
"strings"
"time"
"epochsilicon/pkg/debug"
"epochsilicon/pkg/utils"
"fyne.io/fyne/v2"
@@ -105,7 +105,7 @@ func ShowUpdateDialog(updateInfo *utils.UpdateInfo, currentVersion string, myWin
if err != nil {
progressLabel.SetText(fmt.Sprintf("Download failed: %v", err))
debug.Printf("Download failed: %v", err)
log.Debugf("Download failed: %v", err)
// Re-enable close button
d.SetButtons([]fyne.CanvasObject{
@@ -123,7 +123,7 @@ func ShowUpdateDialog(updateInfo *utils.UpdateInfo, currentVersion string, myWin
err = utils.InstallUpdate(downloadPath)
if err != nil {
progressLabel.SetText(fmt.Sprintf("Installation failed: %v", err))
debug.Printf("Installation failed: %v", err)
log.Debugf("Installation failed: %v", err)
// Re-enable close button
fyne.DoAndWait(func() {

View File

@@ -28,9 +28,10 @@ var (
stopServiceButton *widget.Button
// Option checkboxes
metalHudCheckbox *widget.Check
showTerminalCheckbox *widget.Check
autoDeleteWdbCheckbox *widget.Check
metalHudCheckbox *widget.Check
showTerminalCheckbox *widget.Check
autoDeleteWdbCheckbox *widget.Check
advancedLoggingCheckbox *widget.Check
// Recommended settings button
applyRecommendedSettingsButton *widget.Button