chore: structured timestamped logging across the backend

- uvicorn --log-config (log_config.json): timestamped formatters for uvicorn
  access/error and the app's own "subfeed" loggers (ms precision)
- Log key activity: startup/shutdown, login/denied, token refresh, YouTube API
  errors, subscription imports, sync pause/resume
- Background sync jobs no longer swallow errors silently — failures in RSS poll,
  backfill, enrichment, autotag and resync are logged with tracebacks
This commit is contained in:
npeter83 2026-06-11 04:26:18 +02:00
parent ecaf516429
commit f6c5488566
9 changed files with 86 additions and 7 deletions

View file

@ -1,3 +1,4 @@
import logging
from datetime import datetime, timezone
from authlib.integrations.starlette_client import OAuth, OAuthError
@ -14,6 +15,8 @@ from app.security import encrypt
# (unsubscribe, playlist export). openid/email/profile give us the account identity.
SCOPES = "openid email profile https://www.googleapis.com/auth/youtube"
log = logging.getLogger("subfeed.auth")
router = APIRouter(prefix="/auth", tags=["auth"])
oauth = OAuth()
@ -53,6 +56,7 @@ async def callback(request: Request, db: Session = Depends(get_db)):
email = (userinfo.get("email") or "").lower()
if not email or email not in settings.allowed_email_set:
log.warning("Login denied (not on invite list): %s", email or "<no email>")
raise HTTPException(
status_code=403, detail="This Google account is not on the invite list."
)
@ -81,6 +85,7 @@ async def callback(request: Request, db: Session = Depends(get_db)):
db.commit()
request.session["user_id"] = user.id
log.info("Login: %s (id=%s, role=%s)", email, user.id, user.role)
return RedirectResponse(url="/")