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:
@@ -64,10 +64,10 @@ func (c *Client) do(ctx context.Context, method, path string, body interface{})
|
||||
}
|
||||
bodyReader = bytes.NewReader(data)
|
||||
if c.debug {
|
||||
c.logger.Printf("[CF-DEBUG] %s %s body=%s", method, path, string(data))
|
||||
c.logger.Printf("[DEBUG] [cloudflare] %s %s body=%s", method, path, string(data))
|
||||
}
|
||||
} else if c.debug {
|
||||
c.logger.Printf("[CF-DEBUG] %s %s", method, path)
|
||||
c.logger.Printf("[DEBUG] [cloudflare] %s %s", method, path)
|
||||
}
|
||||
|
||||
url := apiBase + path
|
||||
@@ -91,7 +91,7 @@ func (c *Client) do(ctx context.Context, method, path string, body interface{})
|
||||
}
|
||||
|
||||
if c.debug {
|
||||
c.logger.Printf("[CF-DEBUG] Response %d: %s", resp.StatusCode, string(respBody))
|
||||
c.logger.Printf("[DEBUG] [cloudflare] Response %d: %s", resp.StatusCode, string(respBody))
|
||||
}
|
||||
|
||||
var apiResp apiResponse
|
||||
|
||||
@@ -73,20 +73,20 @@ func (c *Client) GetCustomRulesetID(ctx context.Context, zoneID string) (string,
|
||||
}
|
||||
|
||||
if c.debug {
|
||||
c.logger.Printf("[CF-DEBUG] GetCustomRulesetID: found %d rulesets for zone %s", len(rulesets), zoneID)
|
||||
c.logger.Printf("[DEBUG] [cloudflare] GetCustomRulesetID: found %d rulesets for zone %s", len(rulesets), zoneID)
|
||||
}
|
||||
|
||||
for _, rs := range rulesets {
|
||||
if rs.Phase == wafPhase {
|
||||
if c.debug {
|
||||
c.logger.Printf("[CF-DEBUG] GetCustomRulesetID: matched ruleset %s (phase=%s)", rs.ID, wafPhase)
|
||||
c.logger.Printf("[DEBUG] [cloudflare] GetCustomRulesetID: matched ruleset %s (phase=%s)", rs.ID, wafPhase)
|
||||
}
|
||||
return rs.ID, nil
|
||||
}
|
||||
}
|
||||
|
||||
if c.debug {
|
||||
c.logger.Printf("[CF-DEBUG] GetCustomRulesetID: no ruleset with phase %s found", wafPhase)
|
||||
c.logger.Printf("[DEBUG] [cloudflare] GetCustomRulesetID: no ruleset with phase %s found", wafPhase)
|
||||
}
|
||||
|
||||
return "", nil
|
||||
@@ -112,7 +112,7 @@ func (c *Client) CreateCustomRuleset(ctx context.Context, zoneID string) (string
|
||||
return "", fmt.Errorf("decode created ruleset: %w", err)
|
||||
}
|
||||
|
||||
c.logger.Printf("[CF] Created custom ruleset %s for zone %s", rs.ID, zoneID)
|
||||
c.logger.Printf("[INFO] [cloudflare] Created custom ruleset %s for zone %s", rs.ID, zoneID)
|
||||
return rs.ID, nil
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ func (c *Client) GetRules(ctx context.Context, zoneID, rulesetID string) ([]rule
|
||||
}
|
||||
|
||||
if c.debug {
|
||||
c.logger.Printf("[CF-DEBUG] GetRules: %d total rules in ruleset %s", len(rs.Rules), rulesetID)
|
||||
c.logger.Printf("[DEBUG] [cloudflare] GetRules: %d total rules in ruleset %s", len(rs.Rules), rulesetID)
|
||||
}
|
||||
|
||||
return rs.Rules, nil
|
||||
@@ -159,7 +159,7 @@ func (c *Client) GetFelhomRules(ctx context.Context, zoneID, rulesetID string) (
|
||||
}
|
||||
|
||||
if c.debug {
|
||||
c.logger.Printf("[CF-DEBUG] GetFelhomRules: %d felhom rules out of %d total", len(result), len(rules))
|
||||
c.logger.Printf("[DEBUG] [cloudflare] GetFelhomRules: %d felhom rules out of %d total", len(result), len(rules))
|
||||
}
|
||||
|
||||
return result, nil
|
||||
@@ -185,13 +185,13 @@ func (c *Client) CreateRule(ctx context.Context, zoneID, rulesetID string, r rul
|
||||
|
||||
for _, created := range rs.Rules {
|
||||
if created.Description == r.Description {
|
||||
c.logger.Printf("[CF] Created rule %q → %s", r.Description, created.ID)
|
||||
c.logger.Printf("[INFO] [cloudflare] Created rule %q → %s", r.Description, created.ID)
|
||||
if c.debug {
|
||||
expr := r.Expression
|
||||
if len(expr) > 120 {
|
||||
expr = expr[:120] + "..."
|
||||
}
|
||||
c.logger.Printf("[CF-DEBUG] CreateRule: expression: %s", expr)
|
||||
c.logger.Printf("[DEBUG] [cloudflare] CreateRule: expression: %s", expr)
|
||||
}
|
||||
return created.ID, nil
|
||||
}
|
||||
@@ -209,13 +209,13 @@ func (c *Client) UpdateRule(ctx context.Context, zoneID, rulesetID, ruleID strin
|
||||
c.logger.Printf("[ERROR] [cloudflare] Failed to update WAF rule %s: %v", ruleID, err)
|
||||
return fmt.Errorf("update rule %s: %w", ruleID, err)
|
||||
}
|
||||
c.logger.Printf("[CF] Updated rule %q (%s)", r.Description, ruleID)
|
||||
c.logger.Printf("[INFO] [cloudflare] Updated rule %q (%s)", r.Description, ruleID)
|
||||
if c.debug {
|
||||
expr := r.Expression
|
||||
if len(expr) > 120 {
|
||||
expr = expr[:120] + "..."
|
||||
}
|
||||
c.logger.Printf("[CF-DEBUG] UpdateRule: expression: %s", expr)
|
||||
c.logger.Printf("[DEBUG] [cloudflare] UpdateRule: expression: %s", expr)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -229,7 +229,7 @@ func (c *Client) DeleteRule(ctx context.Context, zoneID, rulesetID, ruleID strin
|
||||
c.logger.Printf("[ERROR] [cloudflare] Failed to delete WAF rule %s: %v", ruleID, err)
|
||||
return fmt.Errorf("delete rule %s: %w", ruleID, err)
|
||||
}
|
||||
c.logger.Printf("[CF] Deleted rule %s", ruleID)
|
||||
c.logger.Printf("[INFO] [cloudflare] Deleted rule %s", ruleID)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -17,12 +17,12 @@ type zone struct {
|
||||
// It tries the exact domain first, then strips subdomains progressively.
|
||||
func (c *Client) GetZoneID(ctx context.Context, domain string) (string, error) {
|
||||
if c.debug {
|
||||
c.logger.Printf("[CF-DEBUG] GetZoneID: looking up zone for domain %q", domain)
|
||||
c.logger.Printf("[DEBUG] [cloudflare] GetZoneID: looking up zone for domain %q", domain)
|
||||
}
|
||||
|
||||
// Try exact domain first (e.g., "demo-felhom.eu")
|
||||
if c.debug {
|
||||
c.logger.Printf("[CF-DEBUG] GetZoneID: trying exact domain %q", domain)
|
||||
c.logger.Printf("[DEBUG] [cloudflare] GetZoneID: trying exact domain %q", domain)
|
||||
}
|
||||
id, err := c.lookupZone(ctx, domain)
|
||||
if err != nil {
|
||||
@@ -40,7 +40,7 @@ func (c *Client) GetZoneID(ctx context.Context, domain string) (string, error) {
|
||||
break
|
||||
}
|
||||
if c.debug {
|
||||
c.logger.Printf("[CF-DEBUG] GetZoneID: trying parent domain %q", parent)
|
||||
c.logger.Printf("[DEBUG] [cloudflare] GetZoneID: trying parent domain %q", parent)
|
||||
}
|
||||
id, err = c.lookupZone(ctx, parent)
|
||||
if err != nil {
|
||||
@@ -73,6 +73,6 @@ func (c *Client) lookupZone(ctx context.Context, name string) (string, error) {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
c.logger.Printf("[CF] Resolved zone %q → %s", name, zones[0].ID)
|
||||
c.logger.Printf("[INFO] [cloudflare] Resolved zone %q → %s", name, zones[0].ID)
|
||||
return zones[0].ID, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user