unify logging with rich

This commit is contained in:
Jakub Miazek
2023-04-10 21:42:06 +02:00
parent 429909344d
commit aa1b9ec867
3 changed files with 14 additions and 27 deletions

View File

@@ -4,11 +4,10 @@ from sqlalchemy.ext.asyncio import AsyncSession, create_async_engine
from sqlalchemy.orm import sessionmaker
from app import config
from app.utils import get_logger
logger = get_logger(__name__)
from app.logging import AppLogger
global_settings = config.get_settings()
logger = AppLogger.__call__().get_logger()
engine = create_async_engine(
global_settings.asyncpg_url,
@@ -18,13 +17,11 @@ engine = create_async_engine(
# expire_on_commit=False will prevent attributes from being expired
# after commit.
AsyncSessionFactory = sessionmaker(
engine, autoflush=False, expire_on_commit=False, class_=AsyncSession
)
AsyncSessionFactory = sessionmaker(engine, autoflush=False, expire_on_commit=False, class_=AsyncSession)
# Dependency
async def get_db() -> AsyncGenerator:
async with AsyncSessionFactory() as session:
logger.debug(f"ASYNC Pool: {engine.pool.status()}")
# logger.debug(f"ASYNC Pool: {engine.pool.status()}")
yield session