fix: standardize log prefixes, remove duplicates, add missing module tags

Second-pass logging cleanup: consistent [LEVEL] [module] format across
all 41 files. Remove stale prefixes ([CF], [SYNC], [SCHED], [API],
[STORAGE], [HEALTH], [ROLLBACK]). Remove 5 duplicate log lines. Gate
ungated DEBUG lines. Fix wrong log levels (restore start WARN→INFO).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-26 21:20:09 +01:00
parent 8e61cd7ec4
commit af1dd14933
41 changed files with 477 additions and 473 deletions
+16 -16
View File
@@ -38,7 +38,7 @@ func RunHealthCheck(cfg *config.Config, cpuCollector *system.CPUCollector, stora
sysInfo := system.GetInfo(hddPath, cpuCollector)
if debug {
logger.Printf("[DEBUG] [HEALTH] Raw values: disk=%.1f%%, hdd=%.1f%% (configured=%v), mem=%.1f%% (%dMB/%dMB), cpu=%.1f%%, temp=%.1f°C (%s)",
logger.Printf("[DEBUG] [monitor] Raw values: disk=%.1f%%, hdd=%.1f%% (configured=%v), mem=%.1f%% (%dMB/%dMB), cpu=%.1f%%, temp=%.1f°C (%s)",
sysInfo.DiskPercent, sysInfo.HDDPercent, sysInfo.HDDConfigured,
sysInfo.MemPercent, sysInfo.UsedMemMB, sysInfo.TotalMemMB,
sysInfo.CPUPercent, sysInfo.TemperatureCelsius, sysInfo.TemperatureSource)
@@ -52,7 +52,7 @@ func RunHealthCheck(cfg *config.Config, cpuCollector *system.CPUCollector, stora
logger.Printf("[WARN] [monitor] Disk (SSD) threshold breached: %.0f%% (limit: %d%%)", sysInfo.DiskPercent, cfg.Monitoring.Thresholds.DiskCritPercent)
}
if debug {
logger.Printf("[DEBUG] [HEALTH] SSD disk: CRITICAL (%.0f%% >= %d%%)", sysInfo.DiskPercent, cfg.Monitoring.Thresholds.DiskCritPercent)
logger.Printf("[DEBUG] [monitor] SSD disk: CRITICAL (%.0f%% >= %d%%)", sysInfo.DiskPercent, cfg.Monitoring.Thresholds.DiskCritPercent)
}
} else if sysInfo.DiskPercent >= float64(cfg.Monitoring.Thresholds.DiskWarnPercent) {
report.Warnings = append(report.Warnings, fmt.Sprintf("SSD disk usage high: %.0f%%", sysInfo.DiskPercent))
@@ -60,12 +60,12 @@ func RunHealthCheck(cfg *config.Config, cpuCollector *system.CPUCollector, stora
logger.Printf("[WARN] [monitor] Disk (SSD) threshold breached: %.0f%% (limit: %d%%)", sysInfo.DiskPercent, cfg.Monitoring.Thresholds.DiskWarnPercent)
}
if debug {
logger.Printf("[DEBUG] [HEALTH] SSD disk: WARN (%.0f%% >= %d%%)", sysInfo.DiskPercent, cfg.Monitoring.Thresholds.DiskWarnPercent)
logger.Printf("[DEBUG] [monitor] SSD disk: WARN (%.0f%% >= %d%%)", sysInfo.DiskPercent, cfg.Monitoring.Thresholds.DiskWarnPercent)
}
} else {
report.Info = append(report.Info, fmt.Sprintf("SSD: %.0f%% used", sysInfo.DiskPercent))
if debug {
logger.Printf("[DEBUG] [HEALTH] SSD disk: OK (%.0f%%)", sysInfo.DiskPercent)
logger.Printf("[DEBUG] [monitor] SSD disk: OK (%.0f%%)", sysInfo.DiskPercent)
}
}
}
@@ -93,12 +93,12 @@ func RunHealthCheck(cfg *config.Config, cpuCollector *system.CPUCollector, stora
logger.Printf("[WARN] [monitor] Memory threshold breached: %.0f%% (limit: %d%%)", sysInfo.MemPercent, cfg.Monitoring.Thresholds.MemoryWarnPercent)
}
if debug {
logger.Printf("[DEBUG] [HEALTH] Memory: WARN (%.0f%% >= %d%%)", sysInfo.MemPercent, cfg.Monitoring.Thresholds.MemoryWarnPercent)
logger.Printf("[DEBUG] [monitor] Memory: WARN (%.0f%% >= %d%%)", sysInfo.MemPercent, cfg.Monitoring.Thresholds.MemoryWarnPercent)
}
} else {
report.Info = append(report.Info, fmt.Sprintf("Memory: %.0f%% used", sysInfo.MemPercent))
if debug {
logger.Printf("[DEBUG] [HEALTH] Memory: OK (%.0f%%)", sysInfo.MemPercent)
logger.Printf("[DEBUG] [monitor] Memory: OK (%.0f%%)", sysInfo.MemPercent)
}
}
}
@@ -111,12 +111,12 @@ func RunHealthCheck(cfg *config.Config, cpuCollector *system.CPUCollector, stora
logger.Printf("[WARN] [monitor] CPU threshold breached: %.0f%% (limit: %d%%)", sysInfo.CPUPercent, cfg.Monitoring.Thresholds.CPUWarnPercent)
}
if debug {
logger.Printf("[DEBUG] [HEALTH] CPU: WARN (%.0f%% >= %d%%)", sysInfo.CPUPercent, cfg.Monitoring.Thresholds.CPUWarnPercent)
logger.Printf("[DEBUG] [monitor] CPU: WARN (%.0f%% >= %d%%)", sysInfo.CPUPercent, cfg.Monitoring.Thresholds.CPUWarnPercent)
}
} else {
report.Info = append(report.Info, fmt.Sprintf("CPU: %.0f%%", sysInfo.CPUPercent))
if debug {
logger.Printf("[DEBUG] [HEALTH] CPU: OK (%.0f%%)", sysInfo.CPUPercent)
logger.Printf("[DEBUG] [monitor] CPU: OK (%.0f%%)", sysInfo.CPUPercent)
}
}
}
@@ -129,12 +129,12 @@ func RunHealthCheck(cfg *config.Config, cpuCollector *system.CPUCollector, stora
logger.Printf("[WARN] [monitor] Temperature threshold breached: %.0f°C (limit: %d°C)", sysInfo.TemperatureCelsius, cfg.Monitoring.Thresholds.TemperatureWarnCelsius)
}
if debug {
logger.Printf("[DEBUG] [HEALTH] Temperature: WARN (%.0f°C >= %d°C)", sysInfo.TemperatureCelsius, cfg.Monitoring.Thresholds.TemperatureWarnCelsius)
logger.Printf("[DEBUG] [monitor] Temperature: WARN (%.0f°C >= %d°C)", sysInfo.TemperatureCelsius, cfg.Monitoring.Thresholds.TemperatureWarnCelsius)
}
} else {
report.Info = append(report.Info, fmt.Sprintf("Temperature: %.0f°C", sysInfo.TemperatureCelsius))
if debug {
logger.Printf("[DEBUG] [HEALTH] Temperature: OK (%.0f°C)", sysInfo.TemperatureCelsius)
logger.Printf("[DEBUG] [monitor] Temperature: OK (%.0f°C)", sysInfo.TemperatureCelsius)
}
}
}
@@ -143,18 +143,18 @@ func RunHealthCheck(cfg *config.Config, cpuCollector *system.CPUCollector, stora
if err := checkDocker(); err != nil {
report.Issues = append(report.Issues, fmt.Sprintf("Docker: %v", err))
if debug {
logger.Printf("[DEBUG] [HEALTH] Docker daemon: FAIL (%v)", err)
logger.Printf("[DEBUG] [monitor] Docker daemon: FAIL (%v)", err)
}
} else {
report.Info = append(report.Info, "Docker: reachable")
if debug {
logger.Printf("[DEBUG] [HEALTH] Docker daemon: OK")
logger.Printf("[DEBUG] [monitor] Docker daemon: OK")
}
}
// 6. Protected containers
if debug {
logger.Printf("[DEBUG] [HEALTH] Checking %d protected containers: %v", len(cfg.Stacks.Protected), cfg.Stacks.Protected)
logger.Printf("[DEBUG] [monitor] Checking %d protected containers: %v", len(cfg.Stacks.Protected), cfg.Stacks.Protected)
}
missingProtected := checkProtectedContainers(cfg.Stacks.Protected)
for _, name := range missingProtected {
@@ -162,9 +162,9 @@ func RunHealthCheck(cfg *config.Config, cpuCollector *system.CPUCollector, stora
}
if debug {
if len(missingProtected) > 0 {
logger.Printf("[DEBUG] [HEALTH] Protected containers missing: %v", missingProtected)
logger.Printf("[DEBUG] [monitor] Protected containers missing: %v", missingProtected)
} else {
logger.Printf("[DEBUG] [HEALTH] All protected containers running")
logger.Printf("[DEBUG] [monitor] All protected containers running")
}
}
@@ -185,7 +185,7 @@ func RunHealthCheck(cfg *config.Config, cpuCollector *system.CPUCollector, stora
}
if debug {
logger.Printf("[DEBUG] [HEALTH] Final status: %s (issues=%d, warnings=%d, info=%d)",
logger.Printf("[DEBUG] [monitor] Final status: %s (issues=%d, warnings=%d, info=%d)",
report.Status, len(report.Issues), len(report.Warnings), len(report.Info))
}
+1 -1
View File
@@ -115,6 +115,6 @@ func (p *Pinger) send(uuid, suffix, body string) error {
lastErr = fmt.Errorf("HTTP %d", resp.StatusCode)
}
p.logger.Printf("[WARN] Health ping failed after 3 attempts (%s): %v", uuid, lastErr)
p.logger.Printf("[WARN] [monitor] Health ping failed after 3 attempts (%s): %v", uuid, lastErr)
return nil // Never let ping failures affect the caller
}
+44 -44
View File
@@ -200,7 +200,7 @@ func (w *StorageWatchdog) handleConnectedProbe(sp settings.StoragePath, state *p
if result.Status == system.ProbeConnected {
if state.consecutiveFailures > 0 {
w.logger.Printf("[DEBUG] [STORAGE] Probe recovered for %s after %d failures", sp.Path, state.consecutiveFailures)
w.logger.Printf("[DEBUG] [storage] Probe recovered for %s after %d failures", sp.Path, state.consecutiveFailures)
}
state.consecutiveFailures = 0
state.lastStatus = "connected"
@@ -209,7 +209,7 @@ func (w *StorageWatchdog) handleConnectedProbe(sp settings.StoragePath, state *p
// Every 60 probes (~5 minutes at 5s interval): emit summary
if state.probeCount >= 60 {
avgLatency := state.totalLatency / time.Duration(state.probeCount)
w.logger.Printf("[DEBUG] [STORAGE] Storage watchdog: %s — %d/%d probes OK (last 5m, avg %dms)",
w.logger.Printf("[DEBUG] [storage] Storage watchdog: %s — %d/%d probes OK (last 5m, avg %dms)",
sp.Path, state.probeOKCount, state.probeCount, avgLatency.Milliseconds())
state.probeCount = 0
state.probeOKCount = 0
@@ -224,11 +224,11 @@ func (w *StorageWatchdog) handleConnectedProbe(sp settings.StoragePath, state *p
// Debug: log immediately on unexpected failure (was connected, now failing)
if w.isDebug() && state.lastStatus == "connected" {
w.logger.Printf("[DEBUG] [STORAGE] Storage probe failed for %s (%d/%d before disconnect): %v",
w.logger.Printf("[DEBUG] [storage] Storage probe failed for %s (%d/%d before disconnect): %v",
sp.Path, state.consecutiveFailures, probeThreshold, result.Err)
}
w.logger.Printf("[WARN] [STORAGE] Probe failed for %s (%d/%d): %v",
w.logger.Printf("[WARN] [storage] Probe failed for %s (%d/%d): %v",
sp.Path, state.consecutiveFailures, probeThreshold, result.Err)
if state.consecutiveFailures >= probeThreshold {
@@ -249,14 +249,14 @@ func (w *StorageWatchdog) handleDisconnect(sp settings.StoragePath, state *pathP
if label == "" {
label = sp.Path
}
w.logger.Printf("[ERROR] [STORAGE] Drive disconnected: %s (%s)", sp.Path, label)
w.logger.Printf("[ERROR] [storage] Drive disconnected: %s (%s)", sp.Path, label)
// 1. Find and stop affected stacks
stoppedStacks := w.stopAffectedStacks(sp.Path)
// 2. Mark disconnected in settings (persists to settings.json)
if err := w.settings.SetDisconnected(sp.Path, true, stoppedStacks); err != nil {
w.logger.Printf("[ERROR] [STORAGE] Failed to mark disconnected: %v", err)
w.logger.Printf("[ERROR] [storage] Failed to mark disconnected: %v", err)
}
// 3. Lazy unmount stale mount (if probe timed out — mount is likely hanging)
@@ -302,7 +302,7 @@ func (w *StorageWatchdog) handleReconnectCheck(ctx context.Context, sp settings.
}
if w.isDebug() {
w.logger.Printf("[DEBUG] [STORAGE] Reconnect check for %s: UUID=%s, mountPath=%s, isAttachWizard=%v",
w.logger.Printf("[DEBUG] [storage] Reconnect check for %s: UUID=%s, mountPath=%s, isAttachWizard=%v",
sp.Path, uuid, mountPath, isAttachWizard)
}
@@ -316,35 +316,35 @@ func (w *StorageWatchdog) handleReconnectCheck(ctx context.Context, sp settings.
if label == "" {
label = sp.Path
}
w.logger.Printf("[INFO] [STORAGE] Drive reconnected (UUID found), attempting remount: %s (%s)", sp.Path, label)
w.logger.Printf("[INFO] [storage] Drive reconnected (UUID found), attempting remount: %s (%s)", sp.Path, label)
if w.isDebug() {
w.logger.Printf("[DEBUG] [STORAGE] UUID %s found at %s, mounting %s (raw=%s, attachWizard=%v)",
w.logger.Printf("[DEBUG] [storage] UUID %s found at %s, mounting %s (raw=%s, attachWizard=%v)",
uuid, uuidPath, sp.Path, rawPath, isAttachWizard)
}
// Attempt remount
if err := w.remount(sp.Path, rawPath, isAttachWizard); err != nil {
w.logger.Printf("[ERROR] [STORAGE] Remount failed for %s: %v", sp.Path, err)
w.logger.Printf("[ERROR] [storage] Remount failed for %s: %v", sp.Path, err)
return // Try again next cycle
}
// Verify with a probe
verifyResult := system.ProbeStoragePath(sp.Path)
if verifyResult.Status != system.ProbeConnected {
w.logger.Printf("[ERROR] [STORAGE] Post-remount probe failed for %s: %v", sp.Path, verifyResult.Err)
w.logger.Printf("[ERROR] [storage] Post-remount probe failed for %s: %v", sp.Path, verifyResult.Err)
if w.isDebug() {
w.logger.Printf("[DEBUG] [STORAGE] Post-mount verification failed for %s: status=%v, err=%v",
w.logger.Printf("[DEBUG] [storage] Post-mount verification failed for %s: status=%v, err=%v",
sp.Path, verifyResult.Status, verifyResult.Err)
}
return
}
if w.isDebug() {
w.logger.Printf("[DEBUG] [STORAGE] Post-mount verification succeeded for %s", sp.Path)
w.logger.Printf("[DEBUG] [storage] Post-mount verification succeeded for %s", sp.Path)
}
w.logger.Printf("[INFO] [STORAGE] Drive successfully remounted: %s (%s)", sp.Path, label)
w.logger.Printf("[INFO] [storage] Drive successfully remounted: %s (%s)", sp.Path, label)
// Clean stale restic locks
w.cleanResticLocks(ctx, sp.Path)
@@ -354,7 +354,7 @@ func (w *StorageWatchdog) handleReconnectCheck(ctx context.Context, sp settings.
// Clear disconnected but preserve StoppedStacks for the restart UI
if err := w.settings.SetDisconnected(sp.Path, false, filteredStacks); err != nil {
w.logger.Printf("[ERROR] [STORAGE] Failed to clear disconnected: %v", err)
w.logger.Printf("[ERROR] [storage] Failed to clear disconnected: %v", err)
}
// Update in-memory state
@@ -400,20 +400,20 @@ func (w *StorageWatchdog) stopAffectedStacks(drivePath string) []string {
// Don't stop protected stacks
if w.cfg.IsProtectedStack(stack.Name) {
w.logger.Printf("[WARN] [STORAGE] Skipping protected stack: %s", stack.Name)
w.logger.Printf("[WARN] [storage] Skipping protected stack: %s", stack.Name)
continue
}
w.logger.Printf("[INFO] [STORAGE] Stopping stack %s (drive disconnected: %s)", stack.Name, drivePath)
w.logger.Printf("[INFO] [storage] Stopping stack %s (drive disconnected: %s)", stack.Name, drivePath)
if err := w.stackProvider.StopStack(stack.Name); err != nil {
w.logger.Printf("[ERROR] [STORAGE] Failed to stop stack %s: %v", stack.Name, err)
w.logger.Printf("[ERROR] [storage] Failed to stop stack %s: %v", stack.Name, err)
continue // Don't add to stopped list if stop failed
}
stopped = append(stopped, stack.Name)
}
if len(stopped) > 0 {
w.logger.Printf("[INFO] [STORAGE] Stopped %d stack(s) due to drive disconnect: %v", len(stopped), stopped)
w.logger.Printf("[INFO] [storage] Stopped %d stack(s) due to drive disconnect: %v", len(stopped), stopped)
}
return stopped
}
@@ -426,18 +426,18 @@ func (w *StorageWatchdog) lazyUnmount(path string) {
// Unmount the bind/main path
cmd := exec.Command("umount", "-l", path)
if out, err := cmd.CombinedOutput(); err != nil {
w.logger.Printf("[WARN] [STORAGE] umount -l %s: %v (%s)", path, err, strings.TrimSpace(string(out)))
w.logger.Printf("[WARN] [storage] umount -l %s: %v (%s)", path, err, strings.TrimSpace(string(out)))
} else {
w.logger.Printf("[INFO] [STORAGE] Lazy unmounted: %s", path)
w.logger.Printf("[INFO] [storage] Lazy unmounted: %s", path)
}
// Then unmount the raw path if it's an attach-wizard drive
if isAttachWizard && rawPath != "" {
cmd = exec.Command("umount", "-l", rawPath)
if out, err := cmd.CombinedOutput(); err != nil {
w.logger.Printf("[WARN] [STORAGE] umount -l %s: %v (%s)", rawPath, err, strings.TrimSpace(string(out)))
w.logger.Printf("[WARN] [storage] umount -l %s: %v (%s)", rawPath, err, strings.TrimSpace(string(out)))
} else {
w.logger.Printf("[INFO] [STORAGE] Lazy unmounted raw: %s", rawPath)
w.logger.Printf("[INFO] [storage] Lazy unmounted raw: %s", rawPath)
}
}
}
@@ -456,19 +456,19 @@ func (w *StorageWatchdog) remount(path, rawPath string, isAttachWizard bool) err
if out, err := cmd.CombinedOutput(); err != nil {
return fmt.Errorf("mount raw %s: %v (%s)", rawPath, err, strings.TrimSpace(string(out)))
}
w.logger.Printf("[INFO] [STORAGE] Mounted raw: %s", rawPath)
w.logger.Printf("[INFO] [storage] Mounted raw: %s", rawPath)
cmd = exec.Command("mount", "-T", hostFstabPath, path)
if out, err := cmd.CombinedOutput(); err != nil {
return fmt.Errorf("mount bind %s: %v (%s)", path, err, strings.TrimSpace(string(out)))
}
w.logger.Printf("[INFO] [STORAGE] Mounted bind: %s", path)
w.logger.Printf("[INFO] [storage] Mounted bind: %s", path)
} else {
cmd := exec.Command("mount", "-T", hostFstabPath, path)
if out, err := cmd.CombinedOutput(); err != nil {
return fmt.Errorf("mount %s: %v (%s)", path, err, strings.TrimSpace(string(out)))
}
w.logger.Printf("[INFO] [STORAGE] Mounted: %s", path)
w.logger.Printf("[INFO] [storage] Mounted: %s", path)
}
return nil
}
@@ -482,11 +482,11 @@ func (w *StorageWatchdog) cleanResticLocks(ctx context.Context, drivePath string
return // No locks dir or no lock files
}
w.logger.Printf("[INFO] [STORAGE] Found %d restic lock file(s) in %s, running unlock", len(entries), repoPath)
w.logger.Printf("[INFO] [storage] Found %d restic lock file(s) in %s, running unlock", len(entries), repoPath)
if w.unlockRepo != nil {
if err := w.unlockRepo(ctx, repoPath); err != nil {
w.logger.Printf("[WARN] [STORAGE] Restic unlock failed for %s: %v", repoPath, err)
w.logger.Printf("[WARN] [storage] Restic unlock failed for %s: %v", repoPath, err)
}
}
}
@@ -529,7 +529,7 @@ func (w *StorageWatchdog) SafeDisconnect(ctx context.Context, path string) (stop
if label == "" {
label = sp.Path
}
w.logger.Printf("[INFO] [STORAGE] Safe disconnect requested: %s (%s)", path, label)
w.logger.Printf("[INFO] [storage] Safe disconnect requested: %s (%s)", path, label)
// 1. Stop affected stacks
stoppedStacks = w.stopAffectedStacks(path)
@@ -544,7 +544,7 @@ func (w *StorageWatchdog) SafeDisconnect(ctx context.Context, path string) (stop
cmd := exec.Command("umount", path)
if out, umountErr := cmd.CombinedOutput(); umountErr != nil {
// Try lazy unmount as fallback
w.logger.Printf("[WARN] [STORAGE] umount %s failed, trying lazy: %v", path, umountErr)
w.logger.Printf("[WARN] [storage] umount %s failed, trying lazy: %v", path, umountErr)
cmd = exec.Command("umount", "-l", path)
if out, umountErr = cmd.CombinedOutput(); umountErr != nil {
return stoppedStacks, fmt.Errorf("umount %s failed: %v (%s)", path, umountErr, strings.TrimSpace(string(out)))
@@ -557,14 +557,14 @@ func (w *StorageWatchdog) SafeDisconnect(ctx context.Context, path string) (stop
if out, umountErr := cmd.CombinedOutput(); umountErr != nil {
cmd = exec.Command("umount", "-l", rawPath)
if out, umountErr = cmd.CombinedOutput(); umountErr != nil {
w.logger.Printf("[WARN] [STORAGE] umount raw %s failed: %v (%s)", rawPath, umountErr, strings.TrimSpace(string(out)))
w.logger.Printf("[WARN] [storage] umount raw %s failed: %v (%s)", rawPath, umountErr, strings.TrimSpace(string(out)))
}
}
}
// 4. Mark disconnected
if setErr := w.settings.SetDisconnected(path, true, stoppedStacks); setErr != nil {
w.logger.Printf("[ERROR] [STORAGE] Failed to mark disconnected: %v", setErr)
w.logger.Printf("[ERROR] [storage] Failed to mark disconnected: %v", setErr)
}
// 5. Update in-memory state
@@ -587,7 +587,7 @@ func (w *StorageWatchdog) SafeDisconnect(ctx context.Context, path string) (stop
go w.pushHubReport()
}
w.logger.Printf("[INFO] [STORAGE] Safe disconnect completed: %s — drive can be removed", path)
w.logger.Printf("[INFO] [storage] Safe disconnect completed: %s — drive can be removed", path)
return stoppedStacks, nil
}
@@ -639,7 +639,7 @@ func (w *StorageWatchdog) Reconnect(ctx context.Context, path string) (stoppedSt
// Clear disconnected, preserve stopped stacks for restart UI
if setErr := w.settings.SetDisconnected(path, false, filteredStacks); setErr != nil {
w.logger.Printf("[ERROR] [STORAGE] Failed to clear disconnected: %v", setErr)
w.logger.Printf("[ERROR] [storage] Failed to clear disconnected: %v", setErr)
}
// Update in-memory state
@@ -661,7 +661,7 @@ func (w *StorageWatchdog) Reconnect(ctx context.Context, path string) (stoppedSt
go w.pushHubReport()
}
w.logger.Printf("[INFO] [STORAGE] Reconnect completed: %s", path)
w.logger.Printf("[INFO] [storage] Reconnect completed: %s", path)
return filteredStacks, nil
}
@@ -678,9 +678,9 @@ func (w *StorageWatchdog) RestartStoppedApps(path string) (started, failed []str
}
for _, name := range stacks {
w.logger.Printf("[INFO] [STORAGE] Starting stack %s (drive reconnected: %s)", name, path)
w.logger.Printf("[INFO] [storage] Starting stack %s (drive reconnected: %s)", name, path)
if err := w.stackProvider.StartStack(name); err != nil {
w.logger.Printf("[ERROR] [STORAGE] Failed to start stack %s: %v", name, err)
w.logger.Printf("[ERROR] [storage] Failed to start stack %s: %v", name, err)
failed = append(failed, name)
} else {
started = append(started, name)
@@ -689,7 +689,7 @@ func (w *StorageWatchdog) RestartStoppedApps(path string) (started, failed []str
// Clear stopped stacks list
if err := w.settings.ClearStoppedStacks(path); err != nil {
w.logger.Printf("[ERROR] [STORAGE] Failed to clear stopped stacks: %v", err)
w.logger.Printf("[ERROR] [storage] Failed to clear stopped stacks: %v", err)
}
return started, failed
@@ -723,7 +723,7 @@ func (w *StorageWatchdog) SimulateDisconnect(ctx context.Context, path string) (
if label == "" {
label = sp.Path
}
w.logger.Printf("[INFO] [STORAGE] [DEBUG-SIM] Simulating disconnect: %s (%s)", path, label)
w.logger.Printf("[INFO] [storage] (simulation) Simulating disconnect: %s (%s)", path, label)
// Mark as simulated so the watchdog skips probing this path
w.simulatedMu.Lock()
@@ -735,7 +735,7 @@ func (w *StorageWatchdog) SimulateDisconnect(ctx context.Context, path string) (
// Step 2: Mark disconnected in settings
if err := w.settings.SetDisconnected(path, true, stoppedStacks); err != nil {
w.logger.Printf("[ERROR] [STORAGE] [DEBUG-SIM] Failed to mark disconnected: %v", err)
w.logger.Printf("[ERROR] [storage] (simulation) Failed to mark disconnected: %v", err)
}
// Step 3: SKIPPED (no lazyUnmount — drive stays physically mounted)
@@ -761,7 +761,7 @@ func (w *StorageWatchdog) SimulateDisconnect(ctx context.Context, path string) (
go w.pushHubReport()
}
w.logger.Printf("[INFO] [STORAGE] [DEBUG-SIM] Disconnect simulated: %s — %d stack(s) stopped", path, len(stoppedStacks))
w.logger.Printf("[INFO] [storage] (simulation) Disconnect simulated: %s — %d stack(s) stopped", path, len(stoppedStacks))
return stoppedStacks, nil
}
@@ -780,7 +780,7 @@ func (w *StorageWatchdog) SimulateReconnect(ctx context.Context, path string) er
if label == "" {
label = sp.Path
}
w.logger.Printf("[INFO] [STORAGE] [DEBUG-SIM] Simulating reconnect: %s (%s)", path, label)
w.logger.Printf("[INFO] [storage] (simulation) Simulating reconnect: %s (%s)", path, label)
// Remove from simulated set
w.simulatedMu.Lock()
@@ -801,7 +801,7 @@ func (w *StorageWatchdog) SimulateReconnect(ctx context.Context, path string) er
// Clear disconnected, preserve stopped stacks for restart UI
if err := w.settings.SetDisconnected(path, false, filteredStacks); err != nil {
w.logger.Printf("[ERROR] [STORAGE] [DEBUG-SIM] Failed to clear disconnected: %v", err)
w.logger.Printf("[ERROR] [storage] (simulation) Failed to clear disconnected: %v", err)
}
// Update in-memory state
@@ -823,7 +823,7 @@ func (w *StorageWatchdog) SimulateReconnect(ctx context.Context, path string) er
go w.pushHubReport()
}
w.logger.Printf("[INFO] [STORAGE] [DEBUG-SIM] Reconnect simulated: %s", path)
w.logger.Printf("[INFO] [storage] (simulation) Reconnect simulated: %s", path)
return nil
}