Better logger

This commit is contained in:
Jonas Linter
2025-10-09 14:29:44 +02:00
parent f05cc9215e
commit a325a443f7
8 changed files with 234 additions and 12 deletions

View File

@@ -1,7 +1,6 @@
import asyncio
import gzip
import json
import logging
import os
import urllib.parse
from collections import defaultdict
@@ -31,6 +30,7 @@ from .config_loader import load_config
from .db import Base, get_database_url
from .db import Customer as DBCustomer
from .db import Reservation as DBReservation
from .logging_config import get_logger, setup_logging
from .rate_limit import (
BURST_RATE_LIMIT,
DEFAULT_RATE_LIMIT,
@@ -40,9 +40,8 @@ from .rate_limit import (
webhook_limiter,
)
# Configure logging
logging.basicConfig(level=logging.INFO)
_LOGGER = logging.getLogger(__name__)
# Configure logging - will be reconfigured during lifespan with actual config
_LOGGER = get_logger(__name__)
# HTTP Basic auth for AlpineBits
security_basic = HTTPBasic()
@@ -168,6 +167,10 @@ async def lifespan(app: FastAPI):
_LOGGER.exception("Failed to load config: ")
config = {}
# Setup logging from config
setup_logging(config)
_LOGGER.info("Application startup initiated")
DATABASE_URL = get_database_url(config)
engine = create_async_engine(DATABASE_URL, echo=False)
AsyncSessionLocal = async_sessionmaker(engine, expire_on_commit=False)