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:
@@ -66,18 +66,18 @@ func (r *Router) geoUpdateSettings(w http.ResponseWriter, req *http.Request) {
|
||||
}
|
||||
|
||||
if err := r.sett.SetGeoRestriction(geo); err != nil {
|
||||
r.logger.Printf("[API] Failed to save geo settings: %v", err)
|
||||
r.logger.Printf("[ERROR] [api] Failed to save geo settings: %v", err)
|
||||
writeJSON(w, http.StatusInternalServerError, apiResponse{OK: false, Error: err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
r.logger.Printf("[API] Geo settings updated: enabled=%v, countries=%v", body.Enabled, body.AllowedCountries)
|
||||
r.logger.Printf("[INFO] [api] Geo settings updated: enabled=%v, countries=%v", body.Enabled, body.AllowedCountries)
|
||||
|
||||
// Trigger async CF sync
|
||||
if r.geoSync != nil {
|
||||
go func() {
|
||||
if err := r.geoSync.Sync(context.Background()); err != nil {
|
||||
r.logger.Printf("[API] Geo sync after settings update failed: %v", err)
|
||||
r.logger.Printf("[ERROR] [api] Geo sync after settings update failed: %v", err)
|
||||
}
|
||||
}()
|
||||
}
|
||||
@@ -93,7 +93,7 @@ func (r *Router) geoTriggerSync(w http.ResponseWriter, _ *http.Request) {
|
||||
|
||||
go func() {
|
||||
if err := r.geoSync.Sync(context.Background()); err != nil {
|
||||
r.logger.Printf("[API] Manual geo sync failed: %v", err)
|
||||
r.logger.Printf("[ERROR] [api] Manual geo sync failed: %v", err)
|
||||
}
|
||||
}()
|
||||
|
||||
@@ -135,18 +135,18 @@ func (r *Router) geoSetAppOverride(w http.ResponseWriter, req *http.Request, app
|
||||
|
||||
override := &settings.AppGeoOverride{AllowedCountries: body.AllowedCountries}
|
||||
if err := r.sett.SetGeoAppOverride(appName, override); err != nil {
|
||||
r.logger.Printf("[API] Failed to save geo override for %s: %v", appName, err)
|
||||
r.logger.Printf("[ERROR] [api] Failed to save geo override for %s: %v", appName, err)
|
||||
writeJSON(w, http.StatusInternalServerError, apiResponse{OK: false, Error: err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
r.logger.Printf("[API] Geo override set for %s: countries=%v", appName, body.AllowedCountries)
|
||||
r.logger.Printf("[INFO] [api] Geo override set for %s: countries=%v", appName, body.AllowedCountries)
|
||||
|
||||
// Trigger async CF sync
|
||||
if r.geoSync != nil {
|
||||
go func() {
|
||||
if err := r.geoSync.Sync(context.Background()); err != nil {
|
||||
r.logger.Printf("[API] Geo sync after app override failed: %v", err)
|
||||
r.logger.Printf("[ERROR] [api] Geo sync after app override failed: %v", err)
|
||||
}
|
||||
}()
|
||||
}
|
||||
@@ -161,18 +161,18 @@ func (r *Router) geoRemoveAppOverride(w http.ResponseWriter, _ *http.Request, ap
|
||||
}
|
||||
|
||||
if err := r.sett.RemoveGeoAppOverride(appName); err != nil {
|
||||
r.logger.Printf("[API] Failed to remove geo override for %s: %v", appName, err)
|
||||
r.logger.Printf("[ERROR] [api] Failed to remove geo override for %s: %v", appName, err)
|
||||
writeJSON(w, http.StatusInternalServerError, apiResponse{OK: false, Error: err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
r.logger.Printf("[API] Geo override removed for %s", appName)
|
||||
r.logger.Printf("[INFO] [api] Geo override removed for %s", appName)
|
||||
|
||||
// Trigger async CF sync
|
||||
if r.geoSync != nil {
|
||||
go func() {
|
||||
if err := r.geoSync.Sync(context.Background()); err != nil {
|
||||
r.logger.Printf("[API] Geo sync after override removal failed: %v", err)
|
||||
r.logger.Printf("[ERROR] [api] Geo sync after override removal failed: %v", err)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
@@ -314,14 +314,14 @@ func (r *Router) listStacks(w http.ResponseWriter, _ *http.Request) {
|
||||
}
|
||||
|
||||
func (r *Router) rescanStacks(w http.ResponseWriter, _ *http.Request) {
|
||||
r.logger.Printf("[API] Manual stack rescan requested")
|
||||
r.logger.Printf("[INFO] [api] Manual stack rescan requested")
|
||||
if err := r.stackMgr.ScanStacks(); err != nil {
|
||||
r.logger.Printf("[API] Stack rescan failed: %v", err)
|
||||
r.logger.Printf("[ERROR] [api] Stack rescan failed: %v", err)
|
||||
writeJSON(w, http.StatusInternalServerError, apiResponse{OK: false, Error: err.Error()})
|
||||
return
|
||||
}
|
||||
stackCount := len(r.stackMgr.GetStacks())
|
||||
r.logger.Printf("[API] Stack rescan completed: %d stacks found", stackCount)
|
||||
r.logger.Printf("[INFO] [api] Stack rescan completed: %d stacks found", stackCount)
|
||||
writeJSON(w, http.StatusOK, apiResponse{
|
||||
OK: true,
|
||||
Message: fmt.Sprintf("Rescan completed: %d stacks found", stackCount),
|
||||
@@ -355,7 +355,7 @@ func (r *Router) getDeployFields(w http.ResponseWriter, _ *http.Request, name st
|
||||
|
||||
func (r *Router) deployStack(w http.ResponseWriter, req *http.Request, name string) {
|
||||
limitBody(w, req)
|
||||
r.logger.Printf("[API] Deploy requested for stack: %s", name)
|
||||
r.logger.Printf("[INFO] [api] Deploy requested for stack: %s", name)
|
||||
r.dbg("deployStack: name=%s contentLength=%d", name, req.ContentLength)
|
||||
|
||||
var body struct {
|
||||
@@ -373,7 +373,7 @@ func (r *Router) deployStack(w http.ResponseWriter, req *http.Request, name stri
|
||||
|
||||
warning, err := r.stackMgr.DeployStack(deployReq)
|
||||
if err != nil {
|
||||
r.logger.Printf("[API] Deploy failed for %s: %v", name, err)
|
||||
r.logger.Printf("[ERROR] [api] Deploy failed for %s: %v", name, err)
|
||||
status := http.StatusInternalServerError
|
||||
if strings.Contains(err.Error(), "already deployed") {
|
||||
status = http.StatusConflict
|
||||
@@ -412,7 +412,7 @@ func (r *Router) deployStack(w http.ResponseWriter, req *http.Request, name stri
|
||||
}
|
||||
|
||||
func (r *Router) actionStack(w http.ResponseWriter, action, name string) {
|
||||
r.logger.Printf("[API] %s requested for stack: %s", action, name)
|
||||
r.logger.Printf("[INFO] [api] %s requested for stack: %s", action, name)
|
||||
r.dbg("actionStack: action=%s name=%s", action, name)
|
||||
|
||||
// Protected stacks only allow restart — block all other actions
|
||||
@@ -483,7 +483,7 @@ func (r *Router) actionStack(w http.ResponseWriter, action, name string) {
|
||||
|
||||
func (r *Router) updateOptionalConfig(w http.ResponseWriter, req *http.Request, name string) {
|
||||
limitBody(w, req)
|
||||
r.logger.Printf("[API] Optional config update requested for stack: %s", name)
|
||||
r.logger.Printf("[INFO] [api] Optional config update requested for stack: %s", name)
|
||||
|
||||
var body struct {
|
||||
Values map[string]string `json:"values"`
|
||||
@@ -494,7 +494,7 @@ func (r *Router) updateOptionalConfig(w http.ResponseWriter, req *http.Request,
|
||||
}
|
||||
|
||||
if err := r.stackMgr.UpdateOptionalConfig(name, body.Values); err != nil {
|
||||
r.logger.Printf("[API] Optional config update failed for %s: %v", name, err)
|
||||
r.logger.Printf("[ERROR] [api] Optional config update failed for %s: %v", name, err)
|
||||
writeJSON(w, http.StatusInternalServerError, apiResponse{OK: false, Error: err.Error()})
|
||||
return
|
||||
}
|
||||
@@ -535,11 +535,11 @@ func (r *Router) toggleIntegration(w http.ResponseWriter, req *http.Request, pro
|
||||
if !body.Enabled {
|
||||
action = "disable"
|
||||
}
|
||||
r.logger.Printf("[API] Integration %s requested: %s:%s", action, provider, target)
|
||||
r.logger.Printf("[INFO] [api] Integration %s requested: %s:%s", action, provider, target)
|
||||
|
||||
state, err := r.integrationMgr.Toggle(req.Context(), provider, target, body.Enabled)
|
||||
if err != nil {
|
||||
r.logger.Printf("[API] Integration toggle failed for %s:%s: %v", provider, target, err)
|
||||
r.logger.Printf("[ERROR] [api] Integration toggle failed for %s:%s: %v", provider, target, err)
|
||||
writeJSON(w, http.StatusInternalServerError, apiResponse{OK: false, Error: err.Error()})
|
||||
return
|
||||
}
|
||||
@@ -605,7 +605,7 @@ func (r *Router) removeStack(w http.ResponseWriter, req *http.Request, name stri
|
||||
return
|
||||
}
|
||||
limitBody(w, req)
|
||||
r.logger.Printf("[API] Remove requested for stack: %s", name)
|
||||
r.logger.Printf("[INFO] [api] Remove requested for stack: %s", name)
|
||||
r.dbg("removeStack: name=%s", name)
|
||||
|
||||
var body struct {
|
||||
@@ -632,7 +632,7 @@ func (r *Router) removeStack(w http.ResponseWriter, req *http.Request, name stri
|
||||
|
||||
resp, err := r.stackMgr.RemoveStack(name, body.RemoveHDDData, backupPaths)
|
||||
if err != nil {
|
||||
r.logger.Printf("[API] Remove failed for %s: %v", name, err)
|
||||
r.logger.Printf("[ERROR] [api] Remove failed for %s: %v", name, err)
|
||||
status := http.StatusInternalServerError
|
||||
if strings.Contains(err.Error(), "protected") {
|
||||
status = http.StatusForbidden
|
||||
@@ -650,7 +650,7 @@ func (r *Router) removeStack(w http.ResponseWriter, req *http.Request, name stri
|
||||
// Clean up cross-drive backup config for this stack
|
||||
if r.sett != nil {
|
||||
if err := r.sett.SetCrossDriveConfig(name, nil); err != nil {
|
||||
r.logger.Printf("[WARN] Failed to clean cross-drive config for %s: %v", name, err)
|
||||
r.logger.Printf("[WARN] [api] Failed to clean cross-drive config for %s: %v", name, err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -674,7 +674,7 @@ func (r *Router) removeStack(w http.ResponseWriter, req *http.Request, name stri
|
||||
|
||||
func (r *Router) deleteStack(w http.ResponseWriter, req *http.Request, name string) {
|
||||
limitBody(w, req)
|
||||
r.logger.Printf("[API] Delete requested for stack: %s", name)
|
||||
r.logger.Printf("[INFO] [api] Delete requested for stack: %s", name)
|
||||
|
||||
var body struct {
|
||||
RemoveHDDData bool `json:"remove_hdd_data"`
|
||||
@@ -685,7 +685,7 @@ func (r *Router) deleteStack(w http.ResponseWriter, req *http.Request, name stri
|
||||
|
||||
resp, err := r.stackMgr.DeleteStack(name, body.RemoveHDDData)
|
||||
if err != nil {
|
||||
r.logger.Printf("[API] Delete failed for %s: %v", name, err)
|
||||
r.logger.Printf("[ERROR] [api] Delete failed for %s: %v", name, err)
|
||||
status := http.StatusInternalServerError
|
||||
if strings.Contains(err.Error(), "protected") {
|
||||
status = http.StatusForbidden
|
||||
@@ -704,13 +704,13 @@ func (r *Router) deleteStack(w http.ResponseWriter, req *http.Request, name stri
|
||||
}
|
||||
|
||||
func (r *Router) triggerSync(w http.ResponseWriter, _ *http.Request) {
|
||||
r.logger.Println("[API] Manual catalog sync requested")
|
||||
r.logger.Println("[INFO] [api] Manual catalog sync requested")
|
||||
result := r.syncer.TriggerSync()
|
||||
if !result.OK {
|
||||
writeJSON(w, http.StatusTooManyRequests, apiResponse{OK: false, Error: result.Message})
|
||||
return
|
||||
}
|
||||
r.logger.Printf("[API] Catalog sync completed: %s", result.Message)
|
||||
r.logger.Printf("[INFO] [api] Catalog sync completed: %s", result.Message)
|
||||
writeJSON(w, http.StatusOK, apiResponse{OK: true, Message: result.Message, Data: result})
|
||||
}
|
||||
|
||||
@@ -783,7 +783,7 @@ func (r *Router) triggerBackup(w http.ResponseWriter, _ *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
r.logger.Println("[API] Manual backup triggered")
|
||||
r.logger.Println("[INFO] [api] Manual backup triggered")
|
||||
go r.backupMgr.RunFullBackup(context.Background())
|
||||
|
||||
writeJSON(w, http.StatusOK, apiResponse{OK: true, Message: "Mentés elindítva"})
|
||||
@@ -979,12 +979,12 @@ func (r *Router) saveCrossBackupConfig(w http.ResponseWriter, req *http.Request,
|
||||
}
|
||||
|
||||
if err := r.sett.SetCrossDriveConfig(name, cfg); err != nil {
|
||||
r.logger.Printf("[API] Failed to save cross-drive config for %s: %v", name, err)
|
||||
r.logger.Printf("[ERROR] [api] Failed to save cross-drive config for %s: %v", name, err)
|
||||
writeJSON(w, http.StatusInternalServerError, apiResponse{OK: false, Error: err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
r.logger.Printf("[API] Cross-drive backup config saved for %s: dest=%s schedule=%s",
|
||||
r.logger.Printf("[INFO] [api] Cross-drive backup config saved for %s: dest=%s schedule=%s",
|
||||
name, body.DestinationPath, body.Schedule)
|
||||
writeJSON(w, http.StatusOK, apiResponse{OK: true, Message: "Cross-drive backup configuration saved"})
|
||||
}
|
||||
@@ -999,10 +999,10 @@ func (r *Router) triggerCrossBackup(w http.ResponseWriter, req *http.Request, na
|
||||
return
|
||||
}
|
||||
|
||||
r.logger.Printf("[API] Cross-drive backup triggered for: %s", name)
|
||||
r.logger.Printf("[INFO] [api] Cross-drive backup triggered for: %s", name)
|
||||
go func() {
|
||||
if err := r.crossDriveRunner.RunAppBackup(context.Background(), name); err != nil {
|
||||
r.logger.Printf("[API] Cross-drive backup failed for %s: %v", name, err)
|
||||
r.logger.Printf("[ERROR] [api] Cross-drive backup failed for %s: %v", name, err)
|
||||
}
|
||||
if r.OnCrossDriveComplete != nil {
|
||||
r.OnCrossDriveComplete()
|
||||
@@ -1037,14 +1037,14 @@ func (r *Router) triggerAllCrossBackups(w http.ResponseWriter, _ *http.Request)
|
||||
writeJSON(w, http.StatusBadRequest, apiResponse{OK: false, Error: "cross-drive runner not available"})
|
||||
return
|
||||
}
|
||||
r.logger.Println("[API] All cross-drive backups triggered")
|
||||
r.logger.Println("[INFO] [api] All cross-drive backups triggered")
|
||||
go func() {
|
||||
ctx := context.Background()
|
||||
if err := r.crossDriveRunner.RunAllScheduled(ctx, "daily"); err != nil {
|
||||
r.logger.Printf("[API] Cross-drive run-all error: %v", err)
|
||||
r.logger.Printf("[ERROR] [api] Cross-drive run-all error: %v", err)
|
||||
}
|
||||
if err := r.crossDriveRunner.RunAllScheduled(ctx, "weekly"); err != nil {
|
||||
r.logger.Printf("[API] Cross-drive run-all weekly error: %v", err)
|
||||
r.logger.Printf("[ERROR] [api] Cross-drive run-all weekly error: %v", err)
|
||||
}
|
||||
if r.OnCrossDriveComplete != nil {
|
||||
r.OnCrossDriveComplete()
|
||||
@@ -1150,7 +1150,7 @@ func (r *Router) selfupdateTrigger(w http.ResponseWriter, _ *http.Request) {
|
||||
writeJSON(w, http.StatusConflict, apiResponse{OK: false, Error: err.Error()})
|
||||
return
|
||||
}
|
||||
r.logger.Println("[API] Manual self-update triggered")
|
||||
r.logger.Println("[INFO] [api] Manual self-update triggered")
|
||||
writeJSON(w, http.StatusOK, apiResponse{OK: true, Message: "Frissítés elindítva"})
|
||||
}
|
||||
|
||||
@@ -1171,7 +1171,7 @@ func (r *Router) configApply(w http.ResponseWriter, req *http.Request) {
|
||||
|
||||
// Validate it's parseable YAML by attempting to load it
|
||||
if _, err := config.LoadFromBytes(body); err != nil {
|
||||
r.logger.Printf("[API] Config apply rejected: invalid YAML: %v", err)
|
||||
r.logger.Printf("[WARN] [api] Config apply rejected: invalid YAML: %v", err)
|
||||
writeJSON(w, http.StatusBadRequest, apiResponse{OK: false, Error: fmt.Sprintf("invalid config YAML: %v", err)})
|
||||
return
|
||||
}
|
||||
@@ -1180,7 +1180,7 @@ func (r *Router) configApply(w http.ResponseWriter, req *http.Request) {
|
||||
// (os.Rename fails on Docker bind mounts with "device or resource busy")
|
||||
tmpPath := r.configPath + ".tmp"
|
||||
if err := os.WriteFile(tmpPath, body, 0644); err != nil {
|
||||
r.logger.Printf("[ERROR] Config apply: failed to write temp file: %v", err)
|
||||
r.logger.Printf("[ERROR] [api] Config apply: failed to write temp file: %v", err)
|
||||
writeJSON(w, http.StatusInternalServerError, apiResponse{OK: false, Error: "failed to write config"})
|
||||
return
|
||||
}
|
||||
@@ -1189,14 +1189,14 @@ func (r *Router) configApply(w http.ResponseWriter, req *http.Request) {
|
||||
os.Remove(tmpPath)
|
||||
// Rename failed (likely Docker bind mount) — write directly
|
||||
if err := os.WriteFile(r.configPath, body, 0644); err != nil {
|
||||
r.logger.Printf("[ERROR] Config apply: failed to write config: %v", err)
|
||||
r.logger.Printf("[ERROR] [api] Config apply: failed to write config: %v", err)
|
||||
writeJSON(w, http.StatusInternalServerError, apiResponse{OK: false, Error: "failed to apply config"})
|
||||
return
|
||||
}
|
||||
r.logger.Printf("[API] Config apply: rename failed, wrote directly (bind mount)")
|
||||
r.logger.Printf("[INFO] [api] Config apply: rename failed, wrote directly (bind mount)")
|
||||
}
|
||||
|
||||
r.logger.Printf("[API] Config applied from Hub (%d bytes), restart needed to take effect", len(body))
|
||||
r.logger.Printf("[INFO] [api] Config applied from Hub (%d bytes), restart needed to take effect", len(body))
|
||||
writeJSON(w, http.StatusOK, apiResponse{OK: true, Message: "Config applied. Restart controller to apply changes."})
|
||||
|
||||
// Push updated infra backup so Hub has fresh config data immediately
|
||||
@@ -1231,10 +1231,10 @@ func (r *Router) triggerAssetSync(w http.ResponseWriter, req *http.Request) {
|
||||
writeJSON(w, http.StatusOK, apiResponse{OK: false, Error: "asset sync not configured"})
|
||||
return
|
||||
}
|
||||
r.logger.Println("[API] Manual asset sync requested")
|
||||
r.logger.Println("[INFO] [api] Manual asset sync requested")
|
||||
go func() {
|
||||
if err := r.assetsSyncer.Sync(context.Background()); err != nil {
|
||||
r.logger.Printf("[WARN] Manual asset sync failed: %v", err)
|
||||
r.logger.Printf("[WARN] [api] Manual asset sync failed: %v", err)
|
||||
}
|
||||
}()
|
||||
writeJSON(w, http.StatusOK, apiResponse{OK: true, Message: "Asset sync started"})
|
||||
@@ -1252,7 +1252,7 @@ func writeJSON(w http.ResponseWriter, status int, v interface{}) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(status)
|
||||
if err := json.NewEncoder(w).Encode(v); err != nil {
|
||||
log.Printf("[ERROR] Failed to write JSON response: %v", err)
|
||||
log.Printf("[ERROR] [api] Failed to write JSON response: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user