Skip to content

Instantly share code, notes, and snippets.

@dishwad
dishwad / logger.py
Last active June 19, 2024 04:04
Logging configuration for FastAPI using Gunicorn + Uvicorn workers
import logging
import sys
import time
from typing import Callable
from fastapi import Request, Response
from fastapi.routing import APIRoute
from gunicorn.glogging import Logger
from loguru import logger
from starlette.background import BackgroundTask