From b25e833f2168c7b8a5f798d7b019cb19d4fd1eda Mon Sep 17 00:00:00 2001 From: grillazz Date: Wed, 1 Sep 2021 09:48:28 +0200 Subject: [PATCH] add rich logger --- the_app/config.py | 7 ++++--- the_app/main.py | 9 ++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/the_app/config.py b/the_app/config.py index df2adaf..8dc4c76 100644 --- a/the_app/config.py +++ b/the_app/config.py @@ -1,10 +1,11 @@ -import logging import os from functools import lru_cache from pydantic import BaseSettings -log = logging.getLogger(__name__) +from the_app.utils import get_logger + +logger = get_logger(__name__) class Settings(BaseSettings): @@ -41,5 +42,5 @@ class Settings(BaseSettings): @lru_cache() def get_settings(): - log.info("Loading config settings from the environment...") + logger.info("Loading config settings from the environment...") return Settings() diff --git a/the_app/main.py b/the_app/main.py index 338f14c..ef0954c 100644 --- a/the_app/main.py +++ b/the_app/main.py @@ -1,13 +1,12 @@ -import logging - from fastapi import FastAPI from the_app.api.nonsense import router as nonsense_router from the_app.api.stuff import router as stuff_router from the_app.database import engine 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") @@ -22,10 +21,10 @@ async def start_db(): @app.on_event("startup") async def startup_event(): - log.info("Starting up...") + logger.info("Starting up...") await start_db() @app.on_event("shutdown") async def shutdown_event(): - log.info("Shutting down...") + logger.info("Shutting down...")