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:
@@ -69,12 +69,12 @@ func (c *MetricsCollector) loop(ctx context.Context) {
|
||||
func (c *MetricsCollector) sampleWith(ctx context.Context) {
|
||||
sys := c.sampleSystem()
|
||||
if err := c.store.InsertSystemMetrics(sys); err != nil {
|
||||
c.logger.Printf("[WARN] Failed to store system metrics: %v", err)
|
||||
c.logger.Printf("[WARN] [metrics] Failed to store system metrics: %v", err)
|
||||
}
|
||||
|
||||
containers := c.sampleContainers(ctx)
|
||||
if err := c.store.InsertContainerMetrics(containers); err != nil {
|
||||
c.logger.Printf("[WARN] Failed to store container metrics: %v", err)
|
||||
c.logger.Printf("[WARN] [metrics] Failed to store container metrics: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ func (c *MetricsCollector) sampleContainers(parentCtx context.Context) []Contain
|
||||
"--format", "{{.Name}}\t{{.CPUPerc}}\t{{.MemUsage}}\t{{.NetIO}}\t{{.BlockIO}}")
|
||||
out, err := cmd.Output()
|
||||
if err != nil {
|
||||
c.logger.Printf("[WARN] docker stats failed: %v", err)
|
||||
c.logger.Printf("[WARN] [metrics] docker stats failed: %v", err)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ func ScanContainerLogs(containerNames []string, since time.Duration, logger *log
|
||||
elapsed := time.Since(start)
|
||||
dbg("log scan completed: %d containers in %s", len(containerNames), elapsed.Round(time.Millisecond))
|
||||
if elapsed > 5*time.Minute && logger != nil {
|
||||
logger.Printf("[WARN] Log scan took %s (>5min) for %d containers", elapsed.Round(time.Second), len(containerNames))
|
||||
logger.Printf("[WARN] [metrics] Log scan took %s (>5min) for %d containers", elapsed.Round(time.Second), len(containerNames))
|
||||
}
|
||||
|
||||
return results
|
||||
@@ -92,7 +92,7 @@ func scanOneContainer(name string, since time.Duration, logger *log.Logger) Cont
|
||||
output, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
if logger != nil {
|
||||
logger.Printf("[DEBUG] logscanner: docker logs %s: %v", name, err)
|
||||
logger.Printf("[DEBUG] [metrics] logscanner: docker logs %s: %v", name, err)
|
||||
}
|
||||
return summary
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ func (s *MetricsStore) GetContainerTelemetry(since time.Time) ([]ContainerTeleme
|
||||
var ct ContainerTelemetry
|
||||
if err := rows.Scan(&ct.ContainerName, &ct.MemoryAvgMB, &ct.MemoryPeakMB,
|
||||
&ct.CPUAvgPercent, &ct.SampleCount); err != nil {
|
||||
log.Printf("[WARN] telemetry row scan failed: %v", err)
|
||||
log.Printf("[WARN] [metrics] telemetry row scan failed: %v", err)
|
||||
continue
|
||||
}
|
||||
results = append(results, ct)
|
||||
|
||||
Reference in New Issue
Block a user