mirror of
http://88.130.71.182:3000/BlitTech/contexta_be.git
synced 2026-06-13 08:45:24 +00:00
- Add new routers: admin, appointments, campaigns - Add storage service and logging config - Add migrations directory and test suite with pytest config - Add supabase_migration_features.sql - Update models, dependencies, config, and existing routers - Remove whatsapp_service (deleted) - Update pyproject.toml and uv.lock dependencies Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
35 lines
1.2 KiB
Python
35 lines
1.2 KiB
Python
import logging
|
|
import os
|
|
|
|
|
|
def configure_logging():
|
|
"""Configure structured JSON logging for the application."""
|
|
log_level = logging.DEBUG if os.getenv("APP_ENV", "development") == "development" else logging.INFO
|
|
|
|
try:
|
|
from pythonjsonlogger import jsonlogger
|
|
|
|
handler = logging.StreamHandler()
|
|
formatter = jsonlogger.JsonFormatter(
|
|
fmt="%(asctime)s %(levelname)s %(name)s %(message)s",
|
|
datefmt="%Y-%m-%dT%H:%M:%S",
|
|
rename_fields={"asctime": "timestamp", "levelname": "level", "name": "logger"},
|
|
)
|
|
handler.setFormatter(formatter)
|
|
except ImportError:
|
|
# Fallback to plain text if pythonjsonlogger not installed yet
|
|
handler = logging.StreamHandler()
|
|
handler.setFormatter(
|
|
logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
|
|
)
|
|
|
|
root_logger = logging.getLogger()
|
|
root_logger.handlers.clear()
|
|
root_logger.addHandler(handler)
|
|
root_logger.setLevel(log_level)
|
|
|
|
# Silence noisy third-party loggers
|
|
logging.getLogger("uvicorn.access").setLevel(logging.WARNING)
|
|
logging.getLogger("httpx").setLevel(logging.WARNING)
|
|
logging.getLogger("httpcore").setLevel(logging.WARNING)
|