change to zerolog

This commit is contained in:
2025-07-23 08:46:53 -07:00
parent 71f044e6e0
commit 8b5be228fe
17 changed files with 223 additions and 222 deletions

View File

@@ -3,12 +3,12 @@ package launcher
import (
"bufio"
"fmt"
"github.com/rs/zerolog/log"
"os"
"os/exec"
"path/filepath"
"sync"
"epochsilicon/pkg/debug"
"epochsilicon/pkg/paths" // Corrected import path
"epochsilicon/pkg/utils" // Corrected import path
@@ -41,7 +41,7 @@ func runGameIntegrated(parentWindow fyne.Window, shellCmd string) error {
// Parse the shell command to extract components
// The shellCmd format is: cd <path> && <envVars> <rosettaExec> <wineloader> <wowExe>
debug.Printf("Parsing shell command: %s", shellCmd)
log.Debug().Msgf("Parsing shell command: %s", shellCmd)
// Create the command without context cancellation
cmd := exec.Command("sh", "-c", shellCmd)
@@ -71,7 +71,7 @@ func runGameIntegrated(parentWindow fyne.Window, shellCmd string) error {
scanner := bufio.NewScanner(stdout)
for scanner.Scan() {
line := scanner.Text()
debug.Printf("GAME STDOUT: %s", line)
log.Debug().Msgf("GAME STDOUT: %s", line)
}
}()
@@ -79,7 +79,7 @@ func runGameIntegrated(parentWindow fyne.Window, shellCmd string) error {
scanner := bufio.NewScanner(stderr)
for scanner.Scan() {
line := scanner.Text()
debug.Printf("GAME STDERR: %s", line)
log.Debug().Msgf("GAME STDERR: %s", line)
}
}()
@@ -93,9 +93,9 @@ func runGameIntegrated(parentWindow fyne.Window, shellCmd string) error {
}()
if err := cmd.Wait(); err != nil {
debug.Printf("Game process ended with error: %v", err)
log.Debug().Msgf("Game process ended with error: %v", err)
} else {
debug.Println("Game process ended successfully")
log.Debug().Msg("Game process ended successfully")
}
}()
@@ -103,7 +103,7 @@ func runGameIntegrated(parentWindow fyne.Window, shellCmd string) error {
}
func LaunchGame(myWindow fyne.Window) {
debug.Println("Launch Game button clicked")
log.Debug().Msg("Launch Game button clicked")
if paths.CrossoverPath == "" {
dialog.ShowError(fmt.Errorf("CrossOver path not set. Please set it in the patcher."), myWindow)
@@ -132,7 +132,7 @@ func LaunchGame(myWindow fyne.Window) {
}
gameMutex.Unlock()
debug.Println("Preparing to launch EpochSilicon...")
log.Debug().Msg("Preparing to launch EpochSilicon...")
wowExePath := filepath.Join(paths.EpochPath, "Project-Epoch.exe")
@@ -163,20 +163,20 @@ func continueLaunch(myWindow fyne.Window, wowExePath string) {
if AutoDeleteWdb {
wdbPath := filepath.Join(paths.EpochPath, "WDB")
if utils.DirExists(wdbPath) {
debug.Printf("Auto-deleting WDB directory: %s", wdbPath)
log.Debug().Msgf("Auto-deleting WDB directory: %s", wdbPath)
if err := os.RemoveAll(wdbPath); err != nil {
debug.Printf("Warning: failed to auto-delete WDB directory: %v", err)
log.Debug().Msgf("Warning: failed to auto-delete WDB directory: %v", err)
// Don't block the launch, just log the error
} else {
debug.Printf("Successfully auto-deleted WDB directory")
log.Debug().Msgf("Successfully auto-deleted WDB directory")
}
} else {
debug.Printf("WDB directory not found, nothing to delete")
log.Debug().Msgf("WDB directory not found, nothing to delete")
}
}
// Since RosettaX87 service is already running, we can directly launch WoW
debug.Println("RosettaX87 service is running. Proceeding to launch WoW.")
log.Debug().Msg("RosettaX87 service is running. Proceeding to launch WoW.")
if paths.CrossoverPath == "" || paths.EpochPath == "" {
dialog.ShowError(fmt.Errorf("CrossOver path or Epoch path is not set. Cannot launch WoW."), myWindow)
@@ -209,21 +209,21 @@ func continueLaunch(myWindow fyne.Window, wowExePath string) {
escapedShellCmd := utils.EscapeStringForAppleScript(shellCmd)
cmd2Script := fmt.Sprintf("tell application \"Terminal\" to do script \"%s\"", escapedShellCmd)
debug.Println("Executing WoW launch command via AppleScript...")
log.Debug().Msg("Executing WoW launch command via AppleScript...")
if !utils.RunOsascript(cmd2Script, myWindow) {
return
}
debug.Println("Launch command executed. Check the new terminal window.")
log.Debug().Msg("Launch command executed. Check the new terminal window.")
} else {
// Use integrated terminal
debug.Printf("Shell command for integrated terminal: %s", shellCmd)
debug.Println("Executing WoW launch command with integrated terminal...")
log.Debug().Msgf("Shell command for integrated terminal: %s", shellCmd)
log.Debug().Msg("Executing WoW launch command with integrated terminal...")
if err := runGameIntegrated(myWindow, shellCmd); err != nil {
dialog.ShowError(fmt.Errorf("failed to launch game: %v", err), myWindow)
return
}
debug.Println("Game launched with integrated terminal. Check the application logs for output.")
log.Debug().Msg("Game launched with integrated terminal. Check the application logs for output.")
}
}