FastAPIRichLogger is a robust and visually appealing logging system for FastAPI applications. Utilizing the power of the rich
library, it enhances the standard logging capabilities with color-coded log levels, detailed request-response data, and a user-friendly format that improves both readability and debugging.
Install FastAPIRichLogger with pip:
pip install fastapirichlogger
To use FastAPIRichLogger in your FastAPI application, follow these steps:
-
Import FastAPIRichLogger:
from fastapirichlogger import FastAPIRichLogger
-
Add Middleware to FastAPI:
app = FastAPI() app.add_middleware(FastAPIRichLogger)
- Color-Coded Logging: Easily distinguish between different log levels thanks to color coding.
- Request-Response Details: Logs include detailed information about HTTP requests and responses.
- Execution Time Tracking: Monitor the time taken for each request to process.
- Automatic Log ID Assignment: Each request gets a unique log identifier for easier tracking.
Below are example images showing the FastAPIRichLogger in action:
- Success Log Example:
- Error Log Example:
Contributions are what make the open-source community an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE.md
for more information.
Kevin Saltarelli - [email protected]
Project Link: https://github.com/kevinqz/fastapirichlogger