refactor: replace log.Printf/fmt.Printf with structured logger

Replace raw log.Printf and fmt.Printf calls in pkg/state, pkg/agent, and pkg/tools with structured logger calls (WarnCF/InfoCF). This ensures warnings and info messages are routed through the configured logging infrastructure instead of raw stderr/stdout.
This commit is contained in:
程智超0668000959
2026-06-08 09:08:30 +08:00
parent 875cf4a2d4
commit 1ab442b12c
3 changed files with 24 additions and 9 deletions
+4 -2
View File
@@ -2,7 +2,6 @@ package agent
import (
"context"
"fmt"
"os"
"path/filepath"
"regexp"
@@ -414,7 +413,10 @@ func compilePatterns(patterns []string) []*regexp.Regexp {
for _, p := range patterns {
re, err := regexp.Compile(p)
if err != nil {
fmt.Printf("Warning: invalid path pattern %q: %v\n", p, err)
logger.WarnCF("agent", "invalid path pattern in compilePatterns", map[string]any{
"pattern": p,
"error": err.Error(),
})
continue
}
compiled = append(compiled, re)