sagaphone/backend/app/logging_config.py
Tim e5b4f54cd8 Scaffold backend (FastAPI/uv) and frontend (SvelteKit/bun)
Backend: FastAPI app with health check, AppError hierarchy, stderr
logging via LOG_LEVEL, ruff+pyright(strict) config, pytest passing.

Frontend: SvelteKit (TS) with prettier, eslint, vitest (unit +
component), adapter-node for self-hosted deployment on Zeus.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-17 22:12:44 +02:00

25 lines
721 B
Python

"""Logging setup for the backend.
Follows the project's output contract: all log output goes to stderr,
level controlled via the LOG_LEVEL env var (default INFO). This is server
logging, not the request/response payload — that stays in FastAPI's
responses.
"""
from __future__ import annotations
import logging
import os
import sys
def configure_logging() -> None:
level_name = os.environ.get("LOG_LEVEL", "INFO").upper()
level = getattr(logging, level_name, logging.INFO)
handler = logging.StreamHandler(sys.stderr)
handler.setFormatter(logging.Formatter("%(asctime)s %(levelname)-5s %(name)s: %(message)s"))
root = logging.getLogger()
root.setLevel(level)
root.handlers = [handler]