Chama setup_logging() no main.py e faz o logger api_podium propagar pro root, pra que as mensagens cheguem no arquivo em logs/. Adiciona saída no console no QueueListener e o shutdown_logging() no lifespan do FastAPI. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
38 lines
No EOL
1,007 B
Python
38 lines
No EOL
1,007 B
Python
import json
|
|
import logging
|
|
from contextlib import asynccontextmanager
|
|
|
|
import uvicorn
|
|
from fastapi import FastAPI
|
|
|
|
from app.core.configs import settings
|
|
from app.logger_config import setup_logging, shutdown_logging
|
|
from app.v1.api import api_router
|
|
|
|
# Configura o logger root (arquivo em logs/ + console); o logger da API propaga pra ele
|
|
setup_logging()
|
|
logger = logging.getLogger('api_podium')
|
|
|
|
@asynccontextmanager
|
|
async def lifespan(app: FastAPI):
|
|
yield
|
|
shutdown_logging() # garante o flush da fila de log no shutdown
|
|
|
|
app = FastAPI(
|
|
title = 'API - Podium',
|
|
version= '0.0.1',
|
|
lifespan=lifespan
|
|
)
|
|
|
|
app.include_router(api_router, prefix='/v1')
|
|
|
|
@app.post("/dados_retorno")
|
|
def dados_retorno(dados_retorno: dict):
|
|
"""
|
|
Rota para vizualizar qualquer retorno do holmes
|
|
"""
|
|
logger.info("Dados retornados do teste")
|
|
logger.info(json.dumps(dados_retorno, ensure_ascii=False))
|
|
|
|
if __name__ == '__main__':
|
|
uvicorn.run(app, host=settings.api.host, port=settings.api.port) |