Skip to content

Commit 3220044

Browse files
authored
Merge pull request #223 from grillazz/switch-logger-to-rotoger
Switch logger to rotoger
2 parents 8293c39 + 325c388 commit 3220044

File tree

2 files changed

+12
-116
lines changed

2 files changed

+12
-116
lines changed

README.md

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<ul>
2525
<li><a href="#make-will-help-you">Make will help you</a></li>
2626
<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>
2828
<li><a href="#setup-user-auth">Setup user auth</a></li>
2929
<li><a href="#setup-local-env-with-uv">Setup local development with uv</a></li>
3030
<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
102102

103103
<p align="right">(<a href="#readme-top">back to top</a>)</p>
104104

105-
### Rainbow logs with rich :rainbow:
105+
### Structured & Asynchronous Logging with Rotoger 🪵
106106

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.
112111

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:
117113

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.
124118

125-
![sample-logs-with-rich](/static/logz.png)
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.
126120

127121
<p align="right">(<a href="#readme-top">back to top</a>)</p>
128122

app/utils/logging.py

Lines changed: 0 additions & 98 deletions
This file was deleted.

0 commit comments

Comments
 (0)