|
7 | 7 | """ |
8 | 8 |
|
9 | 9 |
|
10 | | -import logging |
11 | | -import os |
| 10 | +import logging_config # Ensure logging is configured before other imports |
12 | 11 | from contextlib import asynccontextmanager |
13 | 12 | from fastapi import FastAPI |
14 | 13 | from fastapi.middleware.cors import CORSMiddleware |
15 | 14 |
|
16 | | -from dotenv import load_dotenv |
17 | 15 | import uvicorn |
18 | 16 |
|
19 | 17 | from agents.conversation_agent_factory import ConversationAgentFactory |
|
23 | 21 | from api.api_routes import router as backend_router |
24 | 22 | from api.history_routes import router as history_router |
25 | 23 |
|
26 | | -# Load environment variables |
27 | | -load_dotenv() |
28 | | - |
29 | | -# Configure logging |
30 | | -# Basic application logging (default: INFO level) |
31 | | -AZURE_BASIC_LOGGING_LEVEL = os.getenv("AZURE_BASIC_LOGGING_LEVEL", "INFO").upper() |
32 | | -# Azure package logging (default: WARNING level to suppress INFO) |
33 | | -AZURE_PACKAGE_LOGGING_LEVEL = os.getenv("AZURE_PACKAGE_LOGGING_LEVEL", "WARNING").upper() |
34 | | -# Azure logging packages (default: empty list) |
35 | | -AZURE_LOGGING_PACKAGES = [ |
36 | | - pkg.strip() for pkg in os.getenv("AZURE_LOGGING_PACKAGES", "").split(",") if pkg.strip() |
37 | | -] |
38 | | - |
39 | | -# Basic config: logging.basicConfig(level=logging.INFO) |
40 | | -logging.basicConfig( |
41 | | - level=getattr(logging, AZURE_BASIC_LOGGING_LEVEL, logging.INFO), |
42 | | - format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', |
43 | | - force=True # This ensures the configuration is applied |
44 | | -) |
45 | | - |
46 | | -# Package config: Azure loggers set to WARNING to suppress INFO |
47 | | -for logger_name in AZURE_LOGGING_PACKAGES: |
48 | | - logging.getLogger(logger_name).setLevel(getattr(logging, AZURE_PACKAGE_LOGGING_LEVEL, logging.WARNING)) |
49 | | - |
50 | | -logging.info(f"Logging configured - Basic: {AZURE_BASIC_LOGGING_LEVEL}, Azure packages: {AZURE_PACKAGE_LOGGING_LEVEL}, Packages: {AZURE_LOGGING_PACKAGES}") |
51 | | - |
52 | | - |
53 | 24 | @asynccontextmanager |
54 | 25 | async def lifespan(fastapi_app: FastAPI): |
55 | 26 | """ |
|
0 commit comments