feat: comprehensive debug logging across all controller modules
Add detailed [DEBUG] logging to every controller module when logging.level is set to "debug". Each module with stateful debug uses SetDebug(bool) wired from main.go. Covers stacks, backup, cloudflare, integrations, system, monitor, settings, scheduler, web handlers, storage, metrics, API, selfupdate, and assets. Also includes the app export/import (.fab bundles) feature from v0.32.0 and its debug page integration. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -188,7 +188,7 @@ func FinalizeAttach(req AttachRequest, progress chan<- FormatProgress) (string,
|
||||
}
|
||||
dbg := func(format string, args ...interface{}) {
|
||||
if req.Logger != nil && req.Debug {
|
||||
req.Logger.Printf("[DEBUG] FinalizeAttach: "+format, args...)
|
||||
req.Logger.Printf("[DEBUG] [storage] FinalizeAttach: "+format, args...)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ func FormatAndMount(req FormatRequest, progress chan<- FormatProgress) (string,
|
||||
}
|
||||
dbg := func(format string, args ...interface{}) {
|
||||
if req.Logger != nil && req.Debug {
|
||||
req.Logger.Printf("[DEBUG] FormatAndMount: "+format, args...)
|
||||
req.Logger.Printf("[DEBUG] [storage] FormatAndMount: "+format, args...)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ func MigrateAppData(
|
||||
|
||||
dbg := func(format string, args ...interface{}) {
|
||||
if req.Logger != nil && req.Debug {
|
||||
req.Logger.Printf("[DEBUG] MigrateAppData: "+format, args...)
|
||||
req.Logger.Printf("[DEBUG] [storage] MigrateAppData: "+format, args...)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -101,6 +101,16 @@ func (tx *migrationTx) rollback() {
|
||||
// MigrateDrive performs a full drive migration, moving all apps from source to dest.
|
||||
func (dm *DriveMigrator) MigrateDrive(ctx context.Context, req DriveMigrateRequest, progress chan<- DriveMigrateProgress) error {
|
||||
start := time.Now()
|
||||
debug := dm.Logger != nil
|
||||
|
||||
dbg := func(format string, args ...interface{}) {
|
||||
if debug {
|
||||
dm.Logger.Printf("[DEBUG] [storage] MigrateDrive: "+format, args...)
|
||||
}
|
||||
}
|
||||
_ = dbg // used below
|
||||
|
||||
dbg("starting drive migration: source=%s dest=%s", req.SourcePath, req.DestPath)
|
||||
|
||||
send := func(step, msg string, pct int) {
|
||||
progress <- DriveMigrateProgress{
|
||||
@@ -175,6 +185,14 @@ func (dm *DriveMigrator) MigrateDrive(ctx context.Context, req DriveMigrateReque
|
||||
}
|
||||
}
|
||||
|
||||
dbg("found %d apps on source drive: %v", len(appsToMigrate), func() []string {
|
||||
names := make([]string, len(appsToMigrate))
|
||||
for i, a := range appsToMigrate {
|
||||
names[i] = a.Name
|
||||
}
|
||||
return names
|
||||
}())
|
||||
|
||||
if len(appsToMigrate) == 0 {
|
||||
return fail("A forrás meghajtón nincs telepített alkalmazás", fmt.Errorf("no apps on source"))
|
||||
}
|
||||
@@ -230,6 +248,7 @@ func (dm *DriveMigrator) MigrateDrive(ctx context.Context, req DriveMigrateReque
|
||||
)
|
||||
}
|
||||
|
||||
dbg("estimated data: %s (%d bytes), free on dest: %s (%d bytes)", bytesHuman(totalBytes), totalBytes, bytesHuman(freeBytes), freeBytes)
|
||||
dm.Logger.Printf("[INFO] Drive migration: %s (%s) → %s (%s), %d apps, ~%s data",
|
||||
req.SourcePath, srcLabel, req.DestPath, dstLabel, len(appsToMigrate), bytesHuman(totalBytes))
|
||||
|
||||
@@ -330,11 +349,13 @@ func (dm *DriveMigrator) MigrateDrive(ctx context.Context, req DriveMigrateReque
|
||||
|
||||
if err := rsyncCmd.Wait(); err != nil {
|
||||
stderrWg.Wait()
|
||||
dbg("rsync failed after %s: %v — stderr: %s", time.Since(start).Round(time.Second), err, stderrBuf.String())
|
||||
send("rolling_back", "rsync sikertelen, visszagörgetés...", 0)
|
||||
tx.rollback()
|
||||
return fail("Adatmásolás sikertelen", fmt.Errorf("rsync failed: %w — %s", err, stderrBuf.String()))
|
||||
}
|
||||
stderrWg.Wait()
|
||||
dbg("rsync completed in %s", time.Since(start).Round(time.Second))
|
||||
|
||||
// --- Step 3: Verify copy ---
|
||||
send("verifying", "Másolat ellenőrzése...", 62)
|
||||
@@ -351,6 +372,7 @@ func (dm *DriveMigrator) MigrateDrive(ctx context.Context, req DriveMigrateReque
|
||||
// --- Step 4: Update all app configs ---
|
||||
send("configuring", "Konfiguráció frissítése...", 65)
|
||||
|
||||
dbg("updating HDD_PATH for %d apps", len(appsToMigrate))
|
||||
var configuredApps []string
|
||||
for i, app := range appsToMigrate {
|
||||
// Guard: verify app still exists
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"gitea.dooplex.hu/admin/felhom-controller/internal/util"
|
||||
)
|
||||
@@ -199,7 +200,7 @@ func partitionToParentDisk(devPath string) string {
|
||||
func enrichWithBlkid(disks []BlockDevice, logger *log.Logger, debug bool) {
|
||||
dbg := func(format string, args ...interface{}) {
|
||||
if debug && logger != nil {
|
||||
logger.Printf("[DEBUG] enrichWithBlkid: "+format, args...)
|
||||
logger.Printf("[DEBUG] [storage] enrichWithBlkid: "+format, args...)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -241,10 +242,13 @@ func enrichWithBlkid(disks []BlockDevice, logger *log.Logger, debug bool) {
|
||||
func ScanDisks(logger *log.Logger, debug bool) (*ScanResult, error) {
|
||||
dbg := func(format string, args ...interface{}) {
|
||||
if debug && logger != nil {
|
||||
logger.Printf("[DEBUG] ScanDisks: "+format, args...)
|
||||
logger.Printf("[DEBUG] [storage] ScanDisks: "+format, args...)
|
||||
}
|
||||
}
|
||||
|
||||
dbg("starting disk scan")
|
||||
scanStart := time.Now()
|
||||
|
||||
out, err := exec.Command(
|
||||
"lsblk", "-J", "-b",
|
||||
"-o", "NAME,PATH,SIZE,TYPE,FSTYPE,MOUNTPOINT,MODEL,RM",
|
||||
@@ -337,5 +341,7 @@ func ScanDisks(logger *log.Logger, debug bool) (*ScanResult, error) {
|
||||
enrichWithBlkid(result.AvailableDisks, logger, debug)
|
||||
enrichWithBlkid(result.SystemDisks, logger, debug)
|
||||
|
||||
dbg("disk scan completed in %s", time.Since(scanStart).Round(time.Millisecond))
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user