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:
@@ -38,7 +38,7 @@ func BuildReport(
|
||||
logger.Printf("[INFO] [report] Building system report")
|
||||
}
|
||||
if debug && logger != nil {
|
||||
logger.Printf("[DEBUG] BuildReport: starting — version=%s, storagePaths=%d", version, len(storagePaths))
|
||||
logger.Printf("[DEBUG] [report] BuildReport: starting — version=%s, storagePaths=%d", version, len(storagePaths))
|
||||
}
|
||||
|
||||
r := &Report{
|
||||
@@ -60,7 +60,7 @@ func BuildReport(
|
||||
h := sha256.Sum256(data)
|
||||
r.ConfigHash = hex.EncodeToString(h[:])
|
||||
if debug && logger != nil {
|
||||
logger.Printf("[DEBUG] BuildReport: configHash=%s (%d bytes)", r.ConfigHash[:12]+"...", len(data))
|
||||
logger.Printf("[DEBUG] [report] BuildReport: configHash=%s (%d bytes)", r.ConfigHash[:12]+"...", len(data))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -126,9 +126,9 @@ func BuildReport(
|
||||
}
|
||||
|
||||
if debug && logger != nil {
|
||||
logger.Printf("[DEBUG] BuildReport: system info collected — cpu=%.1f%%, mem=%d/%dMB, temp=%.1fC",
|
||||
logger.Printf("[DEBUG] [report] BuildReport: system info collected — cpu=%.1f%%, mem=%d/%dMB, temp=%.1fC",
|
||||
sysInfo.CPUPercent, sysInfo.UsedMemMB, sysInfo.TotalMemMB, sysInfo.TemperatureCelsius)
|
||||
logger.Printf("[DEBUG] BuildReport: storage entries=%d", len(r.Storage))
|
||||
logger.Printf("[DEBUG] [report] BuildReport: storage entries=%d", len(r.Storage))
|
||||
}
|
||||
|
||||
// Containers
|
||||
@@ -175,7 +175,7 @@ func BuildReport(
|
||||
}
|
||||
|
||||
if debug && logger != nil {
|
||||
logger.Printf("[DEBUG] BuildReport: complete — containers=%d, health=%s, deployed=%d, available=%d, app_telemetry=%d",
|
||||
logger.Printf("[DEBUG] [report] BuildReport: complete — containers=%d, health=%s, deployed=%d, available=%d, app_telemetry=%d",
|
||||
r.Containers.Total, r.Health.Status, len(r.Stacks.Deployed), len(r.Stacks.Available), len(r.AppTelemetry))
|
||||
}
|
||||
|
||||
|
||||
@@ -67,14 +67,14 @@ func BuildInfraBackup(
|
||||
if data, err := os.ReadFile(settingsPath); err == nil {
|
||||
ib.SettingsJSONB64 = base64.StdEncoding.EncodeToString(data)
|
||||
} else if !os.IsNotExist(err) {
|
||||
logger.Printf("[WARN] Infra backup: could not read settings.json: %v", err)
|
||||
logger.Printf("[WARN] [report] Infra backup: could not read settings.json: %v", err)
|
||||
}
|
||||
|
||||
// Read primary restic password (important but non-fatal)
|
||||
if data, err := os.ReadFile(resticPasswordFile); err == nil {
|
||||
ib.ResticPassword = base64.StdEncoding.EncodeToString(data)
|
||||
} else if !os.IsNotExist(err) {
|
||||
logger.Printf("[WARN] Infra backup: could not read restic password file: %v", err)
|
||||
logger.Printf("[WARN] [report] Infra backup: could not read restic password file: %v", err)
|
||||
}
|
||||
|
||||
// Read encryption key for app.yaml secrets (important but non-fatal)
|
||||
@@ -82,7 +82,7 @@ func BuildInfraBackup(
|
||||
if data, err := os.ReadFile(encryptionKeyFile); err == nil {
|
||||
ib.EncryptionKeyB64 = base64.StdEncoding.EncodeToString(data)
|
||||
} else if !os.IsNotExist(err) {
|
||||
logger.Printf("[WARN] Infra backup: could not read encryption key file: %v", err)
|
||||
logger.Printf("[WARN] [report] Infra backup: could not read encryption key file: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,5 +103,6 @@ func BuildInfraBackup(
|
||||
ib.DeployedStacks = []InfraStack{}
|
||||
}
|
||||
|
||||
logger.Printf("[INFO] [report] InfraBackup built successfully (stacks=%d)", len(ib.DeployedStacks))
|
||||
return ib, nil
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ func (p *Pusher) Push(report *Report) error {
|
||||
|
||||
url := p.hubURL + "/api/v1/report"
|
||||
if p.debug {
|
||||
p.logger.Printf("[DEBUG] Push: url=%s payload=%d bytes", url, len(data))
|
||||
p.logger.Printf("[DEBUG] [report] Push: url=%s payload=%d bytes", url, len(data))
|
||||
}
|
||||
|
||||
p.statusMu.Lock()
|
||||
@@ -106,7 +106,7 @@ func (p *Pusher) Push(report *Report) error {
|
||||
resp.Body.Close()
|
||||
|
||||
if resp.StatusCode >= 200 && resp.StatusCode < 300 {
|
||||
p.logger.Printf("[INFO] Hub report pushed successfully (%d bytes)", len(data))
|
||||
p.logger.Printf("[INFO] [report] Hub report pushed successfully (%d bytes)", len(data))
|
||||
p.statusMu.Lock()
|
||||
p.status.LastSuccess = time.Now()
|
||||
p.status.LastError = ""
|
||||
@@ -151,7 +151,7 @@ func (p *Pusher) PushInfraBackup(data []byte) error {
|
||||
|
||||
url := p.hubURL + "/api/v1/infra-backup"
|
||||
if p.debug {
|
||||
p.logger.Printf("[DEBUG] PushInfraBackup: url=%s payload=%d bytes", url, len(data))
|
||||
p.logger.Printf("[DEBUG] [report] PushInfraBackup: url=%s payload=%d bytes", url, len(data))
|
||||
}
|
||||
|
||||
var lastErr error
|
||||
@@ -179,12 +179,12 @@ func (p *Pusher) PushInfraBackup(data []byte) error {
|
||||
resp.Body.Close()
|
||||
|
||||
if resp.StatusCode >= 200 && resp.StatusCode < 300 {
|
||||
p.logger.Printf("[INFO] Infra backup pushed to Hub (%d bytes)", len(data))
|
||||
p.logger.Printf("[INFO] [report] Infra backup pushed to Hub (%d bytes)", len(data))
|
||||
return nil
|
||||
}
|
||||
lastErr = fmt.Errorf("HTTP %d", resp.StatusCode)
|
||||
if p.debug {
|
||||
p.logger.Printf("[DEBUG] PushInfraBackup: attempt %d failed — HTTP %d", attempt+1, resp.StatusCode)
|
||||
p.logger.Printf("[DEBUG] [report] PushInfraBackup: attempt %d failed — HTTP %d", attempt+1, resp.StatusCode)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -221,7 +221,7 @@ func (p *Pusher) PushOnce(report *Report) error {
|
||||
resp.Body.Close()
|
||||
|
||||
if resp.StatusCode >= 200 && resp.StatusCode < 300 {
|
||||
p.logger.Printf("[INFO] Hub push-once sent (%d bytes)", len(data))
|
||||
p.logger.Printf("[INFO] [report] Hub push-once sent (%d bytes)", len(data))
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("hub push-once: HTTP %d", resp.StatusCode)
|
||||
|
||||
Reference in New Issue
Block a user