Standardize codebase consistency: naming, JSON tags, logging, error wrapping
- JSON tags: fix snake_case to camelCase in dnsmasq (configFile, domainsConfigured, lastRestart), crowdsec Machine (lastPush, lastHeartbeat), network (primaryIP, primaryInterface). cscli raw parsing structs keep snake_case to match CLI output. - Error wrapping: fix %v to %w in enableAuthelia for proper error chain preservation - Naming: rename dnsmasq.ConfigGenerator to dnsmasq.Manager (matches all other packages), rename ServiceStatus to Status in dnsmasq and haproxy (matches authelia, crowdsec, etc.) - Logging: standardize all slog calls to use "component" key instead of message prefixes. Affects reconcile, dnsfilter, ddns — now consistent with dnsmasq, haproxy, nftables, sse.
This commit is contained in:
@@ -315,7 +315,7 @@ func (m *Manager) UpdateLists(ctx context.Context) error {
|
||||
continue
|
||||
}
|
||||
|
||||
slog.Info("dns-filter: downloading list", "name", bl.Name, "url", bl.URL)
|
||||
slog.Info("downloading list", "component", "dns-filter", "name", bl.Name, "url", bl.URL)
|
||||
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, bl.URL, nil)
|
||||
if err != nil {
|
||||
@@ -329,7 +329,7 @@ func (m *Manager) UpdateLists(ctx context.Context) error {
|
||||
if err != nil {
|
||||
bl.LastError = fmt.Sprintf("download failed: %v", err)
|
||||
changed = true
|
||||
slog.Warn("dns-filter: download failed", "name", bl.Name, "error", err)
|
||||
slog.Warn("download failed", "component", "dns-filter", "name", bl.Name, "error", err)
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -337,7 +337,7 @@ func (m *Manager) UpdateLists(ctx context.Context) error {
|
||||
resp.Body.Close()
|
||||
bl.LastError = fmt.Sprintf("HTTP %d", resp.StatusCode)
|
||||
changed = true
|
||||
slog.Warn("dns-filter: download failed", "name", bl.Name, "status", resp.StatusCode)
|
||||
slog.Warn("download failed", "component", "dns-filter", "name", bl.Name, "status", resp.StatusCode)
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -393,7 +393,7 @@ func (m *Manager) Compile() (int, error) {
|
||||
|
||||
domains, err := ParseFile(cachePath)
|
||||
if err != nil {
|
||||
slog.Warn("dns-filter: failed to parse list", "name", bl.Name, "error", err)
|
||||
slog.Warn("failed to parse list", "component", "dns-filter", "name", bl.Name, "error", err)
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -446,7 +446,7 @@ func (m *Manager) Compile() (int, error) {
|
||||
// Update entry counts and save
|
||||
_ = m.SaveFilterData(fd)
|
||||
|
||||
slog.Info("dns-filter: compiled blocklist", "domains", len(sorted))
|
||||
slog.Info("compiled blocklist", "component", "dns-filter", "domains", len(sorted))
|
||||
return len(sorted), nil
|
||||
}
|
||||
|
||||
@@ -496,7 +496,7 @@ func (m *Manager) GetQueryStats() *QueryStats {
|
||||
cmd := exec.Command("sudo", "journalctl", "-u", "dnsmasq", "--since", "24 hours ago", "--no-pager", "-o", "cat")
|
||||
output, err := cmd.Output()
|
||||
if err != nil {
|
||||
slog.Debug("dns-filter: failed to read dnsmasq journal", "error", err)
|
||||
slog.Debug("failed to read dnsmasq journal", "component", "dns-filter", "error", err)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user