change to zerolog
This commit is contained in:
@@ -2,12 +2,12 @@ package launcher
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/rs/zerolog/log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"epochsilicon/pkg/debug"
|
||||
"epochsilicon/pkg/paths"
|
||||
)
|
||||
|
||||
@@ -25,20 +25,20 @@ var RecommendedSettings = map[string]string{
|
||||
// Returns true if all settings are correctly applied, false otherwise
|
||||
func CheckRecommendedSettings() bool {
|
||||
if paths.EpochPath == "" {
|
||||
debug.Printf("Epoch path not set, cannot check Config.wtf")
|
||||
log.Debug().Msgf("Epoch path not set, cannot check Config.wtf")
|
||||
return false
|
||||
}
|
||||
|
||||
configPath := filepath.Join(paths.EpochPath, "WTF", "Config.wtf")
|
||||
|
||||
if _, err := os.Stat(configPath); os.IsNotExist(err) {
|
||||
debug.Printf("Config.wtf not found at %s", configPath)
|
||||
log.Debug().Msgf("Config.wtf not found at %s", configPath)
|
||||
return false
|
||||
}
|
||||
|
||||
content, err := os.ReadFile(configPath)
|
||||
if err != nil {
|
||||
debug.Printf("Failed to read Config.wtf: %v", err)
|
||||
log.Debug().Msgf("Failed to read Config.wtf: %v", err)
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -47,12 +47,12 @@ func CheckRecommendedSettings() bool {
|
||||
// Check each recommended setting
|
||||
for setting, expectedValue := range RecommendedSettings {
|
||||
if !isSettingCorrect(configText, setting, expectedValue) {
|
||||
debug.Printf("Setting %s not found or incorrect in Config.wtf", setting)
|
||||
log.Debug().Msgf("Setting %s not found or incorrect in Config.wtf", setting)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
debug.Printf("All recommended settings are correctly applied")
|
||||
log.Debug().Msgf("All recommended settings are correctly applied")
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ func ApplyRecommendedSettings() error {
|
||||
if content, err := os.ReadFile(configPath); err == nil {
|
||||
configText = string(content)
|
||||
} else {
|
||||
debug.Printf("Config.wtf not found, creating new file")
|
||||
log.Debug().Msgf("Config.wtf not found, creating new file")
|
||||
configText = ""
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ func ApplyRecommendedSettings() error {
|
||||
return fmt.Errorf("failed to write Config.wtf: %v", err)
|
||||
}
|
||||
|
||||
debug.Printf("Successfully applied recommended settings to Config.wtf")
|
||||
log.Debug().Msgf("Successfully applied recommended settings to Config.wtf")
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -120,14 +120,14 @@ func updateOrAddSetting(configText, setting, value string) string {
|
||||
if re.MatchString(configText) {
|
||||
// Replace existing setting
|
||||
configText = re.ReplaceAllString(configText, newSetting)
|
||||
debug.Printf("Updated setting %s to %s", setting, value)
|
||||
log.Debug().Msgf("Updated setting %s to %s", setting, value)
|
||||
} else {
|
||||
// Add new setting
|
||||
if configText != "" && !strings.HasSuffix(configText, "\n") {
|
||||
configText += "\n"
|
||||
}
|
||||
configText += newSetting + "\n"
|
||||
debug.Printf("Added new setting %s with value %s", setting, value)
|
||||
log.Debug().Msgf("Added new setting %s with value %s", setting, value)
|
||||
}
|
||||
|
||||
return configText
|
||||
|
Reference in New Issue
Block a user