|
24 | 24 | <ul> |
25 | 25 | <li><a href="#make-will-help-you">Make will help you</a></li> |
26 | 26 | <li><a href="#how-to-feed-database">How to feed database</a></li> |
27 | | - <li><a href="#rainbow-logs-with-rich">Rainbow logs with rich</a></li> |
| 27 | + <li><a href="#structured-asynchronous-logging-with-rotoger">Structured & Asynchronous Logging with Rotoger</a></li> |
28 | 28 | <li><a href="#setup-user-auth">Setup user auth</a></li> |
29 | 29 | <li><a href="#setup-local-env-with-uv">Setup local development with uv</a></li> |
30 | 30 | <li><a href="#import-xlsx-files-with-polars-and-calamine">Import xlsx files with polars and calamine</a></li> |
@@ -102,27 +102,21 @@ Next models were generated with https://github.com/agronholm/sqlacodegen |
102 | 102 |
|
103 | 103 | <p align="right">(<a href="#readme-top">back to top</a>)</p> |
104 | 104 |
|
105 | | -### Rainbow logs with rich :rainbow: |
| 105 | +### Structured & Asynchronous Logging with Rotoger 🪵 |
106 | 106 |
|
107 | | -To enhance the developer experience when viewing logs with extensive information from multiple emitters |
108 | | -(which are particularly useful during development), this project uses the [rich](https://github.com/Textualize/rich) library. |
109 | | -Event with the superpowers of [rich](https://github.com/Textualize/rich), reading logs can be challenging. |
110 | | -The [rich](https://github.com/Textualize/rich) library is highly beneficial, but integrating it properly as a logger object |
111 | | -and maintaining it as a singleton took some effort. |
| 107 | +To elevate the logging capabilities beyond simple colored output, |
| 108 | +this project has transitioned to [Rotoger](https://github.com/tinyplugins/rotoger). |
| 109 | +This powerful library provides a comprehensive, production-ready logging setup for modern asynchronous applications, |
| 110 | +addressing challenges like log management, performance, and readability. |
112 | 111 |
|
113 | | -To address the following needs: |
114 | | -- Difficulty in finding specific information in logs. |
115 | | -- Avoiding the complexity of setting up an ELK stack for log management. |
116 | | -- Speeding up the debugging process. |
| 112 | +Rotoger is built upon the excellent [structlog](http://structlog.org/) library and brings several key advantages: |
117 | 113 |
|
118 | | -he following steps were taken to integrate [rich](https://github.com/Textualize/rich) into the project: |
119 | | -1. Configure emitters using the [logging-uvicorn.json](https://github.com/grillazz/fastapi-sqlalchemy-asyncpg/blob/main/logging-uvicorn.json) |
120 | | - or use [logging-granian.json](https://github.com/grillazz/fastapi-sqlalchemy-asyncpg/blob/main/logging-granian.json) for granian |
121 | | -2. Eliminate duplicates, such as SQLAlchemy echo, by using separate handlers. |
122 | | -3. Maintain the logger as a singleton to prevent multiple instances. |
123 | | -4. Add the --log-config ./logging-uvicorn.json parameter to Uvicorn or --log-config ./logging-granian.json to Granian. |
| 114 | +- `Structured Logging`: By using structlog, all log entries are generated as structured data (JSON), making them machine-readable and significantly easier to query, parse, and analyze in log management systems. |
| 115 | +- `Asynchronous & Non-Blocking`: Designed for async frameworks like FastAPI, Rotoger performs logging operations in a non-blocking manner. This ensures that I/O-bound logging tasks do not hold up the event loop, maintaining high application performance. |
| 116 | +- `High-Performance JSON`: It leverages orjson for serialization, which is one of the fastest JSON libraries for Python. This minimizes the overhead of converting log records to JSON strings. |
| 117 | +- `Built-in Log Rotation`: Rotoger implements its own log rotation mechanism in Python, allowing you to manage log file sizes and retention policies directly within your application without relying on external tools like logrotate. |
124 | 118 |
|
125 | | - |
| 119 | +This setup solves common logging pain points in production environments, such as managing large log files, ensuring logs don't impact performance, and making logs easily searchable. |
126 | 120 |
|
127 | 121 | <p align="right">(<a href="#readme-top">back to top</a>)</p> |
128 | 122 |
|
|
0 commit comments