CRITICAL FIX: Robust DB connection + drops attribute + no duplicate logging
Some checks failed
CI / Frontend Lint & Type Check (push) Has been cancelled
CI / Frontend Build (push) Has been cancelled
CI / Backend Lint (push) Has been cancelled
CI / Backend Tests (push) Has been cancelled
CI / Docker Build (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
Deploy / Build & Push Images (push) Has been cancelled
Deploy / Deploy to Server (push) Has been cancelled
Deploy / Notify (push) Has been cancelled

This commit is contained in:
2025-12-17 12:03:40 +01:00
parent 52770986cd
commit e8d23e8a49

View File

@ -63,21 +63,22 @@ SWITCH_CONFIG = {
} }
# Setup logging (avoid duplicate handlers) # Setup logging (avoid duplicate handlers)
logger = logging.getLogger("zone_sync") logger = logging.getLogger("pounce_zone_sync")
if not logger.handlers: logger.setLevel(logging.INFO)
logger.setLevel(logging.INFO) if not logger.handlers: # Only add handlers once
formatter = logging.Formatter('%(asctime)s [%(levelname)s] %(message)s') formatter = logging.Formatter('%(asctime)s [%(levelname)s] %(message)s')
# Console handler # Console handler
console_handler = logging.StreamHandler() console = logging.StreamHandler()
console_handler.setFormatter(formatter) console.setFormatter(formatter)
logger.addHandler(console_handler) logger.addHandler(console)
# File handler
# File handler (if directory exists) try:
if LOG_FILE.parent.exists(): LOG_FILE.parent.mkdir(parents=True, exist_ok=True)
file_handler = logging.FileHandler(LOG_FILE) file_handler = logging.FileHandler(LOG_FILE)
file_handler.setFormatter(formatter) file_handler.setFormatter(formatter)
logger.addHandler(file_handler) logger.addHandler(file_handler)
except Exception:
pass # File logging optional
class ZoneSyncResult: class ZoneSyncResult: