feat: comprehensive INFO/WARN/ERROR logging across all controller modules

Add structured operational logging at INFO, WARN, and ERROR levels to
every controller module. Standardize custom prefixes ([GEO], [SCHED],
[SYNC]) to use [INFO/WARN/ERROR] [module] format. Fix misleveled logs
(WARN->ERROR for data loss scenarios, WARN->INFO for routine operations).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-26 19:58:27 +01:00
parent 95c821deb2
commit 8e61cd7ec4
44 changed files with 326 additions and 44 deletions
+2
View File
@@ -67,5 +67,7 @@ func ClearState(dataDir string, logger *log.Logger) {
path := filepath.Join(dataDir, stateFileName)
if err := os.Remove(path); err != nil && !os.IsNotExist(err) {
logger.Printf("[WARN] Failed to clear update state file: %v", err)
return
}
logger.Printf("[INFO] [selfupdate] Update state cleared")
}
@@ -144,6 +144,9 @@ func (u *Updater) CheckForUpdate() CheckResult {
cmp := latestVer.Compare(currentVer)
if cmp > 0 {
result.UpdateAvailable = true
u.logger.Printf("[INFO] [selfupdate] Update available: %s → %s", u.currentVer, latestStr)
} else {
u.logger.Printf("[INFO] [selfupdate] Current version %s is up to date", u.currentVer)
}
u.dbg("version comparison: current=%s (%d.%d.%d), latest=%s (%d.%d.%d), cmp=%d, updateAvailable=%v",
@@ -422,8 +425,10 @@ func (u *Updater) performUpdate(targetVersion, targetImage, previousImage, initi
// updateComposeFile reads the compose file, replaces the image tag, and writes it back atomically.
func (u *Updater) updateComposeFile(newImage string) error {
u.logger.Printf("[INFO] [selfupdate] Updating compose file")
data, err := os.ReadFile(u.composePath)
if err != nil {
u.logger.Printf("[ERROR] [selfupdate] Failed to update compose file: %v", err)
return fmt.Errorf("reading compose file: %w", err)
}
@@ -441,15 +446,18 @@ func (u *Updater) updateComposeFile(newImage string) error {
newData := re.ReplaceAll(data, []byte("${1}"+newImage))
if bytes.Equal(data, newData) {
u.logger.Printf("[ERROR] [selfupdate] Failed to update compose file: no image line found to replace")
return fmt.Errorf("no image line found to replace in compose file")
}
// Atomic write: write to .tmp, then rename
tmpPath := u.composePath + ".tmp"
if err := os.WriteFile(tmpPath, newData, 0644); err != nil {
u.logger.Printf("[ERROR] [selfupdate] Failed to update compose file: %v", err)
return fmt.Errorf("writing temp compose file: %w", err)
}
if err := os.Rename(tmpPath, u.composePath); err != nil {
u.logger.Printf("[ERROR] [selfupdate] Failed to update compose file: %v", err)
return fmt.Errorf("renaming compose file: %w", err)
}