A simple loguru wrapper for our use
logger_manaager_fastapi.py is a custom logger with error highliting with colors and dynamic tracing of API requests. It is used in the Atomosphere project to log API requests and responses in a clear and concise way.
----------- ON MAIN ADD:
from elogger.logger_manager_fastapi import setup_logging
from asgi_correlation_id import CorrelationIdMiddleware
setup_logging()
logger = logging.getLogger(__name__)
app = FastAPI(docs_url=None)
app.add_middleware(
CorrelationIdMiddleware,
header_name="X-Request-ID",
update_request_header=True,
)
----------- ON OTHER MODULES ADD:
import logging
logging.debug("This is a debug log")
logging.info("This is an info log")
logging.warning("This is a warning log")
logging.error("This is an error log")
logging.critical("This is a critical log")
