Skip to content

Commit 522c8e8

Browse files
fix(api): centralizza configurazione logging per visibilità log pipeline
1 parent e8c05eb commit 522c8e8

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and the project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.
1010
### Fixed
1111
- Frontend API calls now include credentials for proper session authentication
1212
- Ollama context size reduced from 8192 to 2048 to match nomic-embed-text model limit
13+
- Centralized logging configuration for consistent pipeline logs visibility
1314

1415
## [1.1.2] - 2025-12-02
1516

api/main.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,26 @@
44
Provides REST API for ragify operations, MCP SSE transport, and serves the frontend SPA.
55
"""
66

7+
import logging
78
import os
9+
import sys
810
import time
911
from contextlib import asynccontextmanager
1012
from pathlib import Path
1113

14+
# Configure logging early, before any other imports
15+
logging.basicConfig(
16+
level=logging.INFO,
17+
format='%(asctime)s [%(levelname)s] %(name)s: %(message)s',
18+
datefmt='%Y-%m-%d %H:%M:%S',
19+
handlers=[logging.StreamHandler(sys.stdout)],
20+
force=True # Override any existing configuration
21+
)
22+
# Disable buffering for real-time logs
23+
sys.stdout.reconfigure(line_buffering=True) if hasattr(sys.stdout, 'reconfigure') else None
24+
25+
logger = logging.getLogger(__name__)
26+
1227
from fastapi import FastAPI, Request
1328
from fastapi.staticfiles import StaticFiles
1429
from fastapi.responses import FileResponse, JSONResponse
@@ -40,10 +55,10 @@
4055
async def lifespan(app: FastAPI):
4156
"""Application lifespan handler."""
4257
# Startup
43-
print(f"Ragify API starting on port {API_PORT}")
58+
logger.info(f"Ragify API starting on port {API_PORT}")
4459
yield
4560
# Shutdown
46-
print("Ragify API shutting down")
61+
logger.info("Ragify API shutting down")
4762

4863

4964
app = FastAPI(

api/routes/upload.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
from fastapi import APIRouter, HTTPException, UploadFile, File, Form, BackgroundTasks
1818
from pydantic import BaseModel
1919

20-
# Setup logging
21-
logging.basicConfig(level=logging.INFO)
2220
logger = logging.getLogger(__name__)
2321

2422
# Add project root to path for imports

0 commit comments

Comments
 (0)