mirror of
https://github.com/grillazz/fastapi-sqlalchemy-asyncpg.git
synced 2025-08-26 16:40:40 +03:00
add rich logger
This commit is contained in:
parent
ec71ff58b1
commit
b25e833f21
@ -1,10 +1,11 @@
|
|||||||
import logging
|
|
||||||
import os
|
import os
|
||||||
from functools import lru_cache
|
from functools import lru_cache
|
||||||
|
|
||||||
from pydantic import BaseSettings
|
from pydantic import BaseSettings
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
from the_app.utils import get_logger
|
||||||
|
|
||||||
|
logger = get_logger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class Settings(BaseSettings):
|
class Settings(BaseSettings):
|
||||||
@ -41,5 +42,5 @@ class Settings(BaseSettings):
|
|||||||
|
|
||||||
@lru_cache()
|
@lru_cache()
|
||||||
def get_settings():
|
def get_settings():
|
||||||
log.info("Loading config settings from the environment...")
|
logger.info("Loading config settings from the environment...")
|
||||||
return Settings()
|
return Settings()
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
import logging
|
|
||||||
|
|
||||||
from fastapi import FastAPI
|
from fastapi import FastAPI
|
||||||
|
|
||||||
from the_app.api.nonsense import router as nonsense_router
|
from the_app.api.nonsense import router as nonsense_router
|
||||||
from the_app.api.stuff import router as stuff_router
|
from the_app.api.stuff import router as stuff_router
|
||||||
from the_app.database import engine
|
from the_app.database import engine
|
||||||
from the_app.models.base import Base
|
from the_app.models.base import Base
|
||||||
|
from the_app.utils import get_logger
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
logger = get_logger(__name__)
|
||||||
|
|
||||||
app = FastAPI(title="Stuff And Nonsense", version="0.2")
|
app = FastAPI(title="Stuff And Nonsense", version="0.2")
|
||||||
|
|
||||||
@ -22,10 +21,10 @@ async def start_db():
|
|||||||
|
|
||||||
@app.on_event("startup")
|
@app.on_event("startup")
|
||||||
async def startup_event():
|
async def startup_event():
|
||||||
log.info("Starting up...")
|
logger.info("Starting up...")
|
||||||
await start_db()
|
await start_db()
|
||||||
|
|
||||||
|
|
||||||
@app.on_event("shutdown")
|
@app.on_event("shutdown")
|
||||||
async def shutdown_event():
|
async def shutdown_event():
|
||||||
log.info("Shutting down...")
|
logger.info("Shutting down...")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user