Logust¶
Documentation: https://yamaaaaaa31.github.io/logust/
Source Code: https://github.com/yamaaaaaa31/logust
Logust is a logging library for Python. Its API follows loguru, and the hot path (formatting, serialization and file I/O) is written in Rust.
The key features are:
- Fast: Rust core for formatting, JSON serialization and file writes. Tens of times faster than
loggingandloguru. See the benchmarks. - Zero config: one import and you get colored output with time, level and caller info.
- Familiar: the loguru API (
logger.add(),bind(),catch(),opt()...). Migrating is mostly changing the import. - Files done right: size and time based rotation, retention and compression, with optional background writes.
- Structured: JSON output with
serialize=True, and context withbind()andcontextualize(). - Production ready: exception capture with rich tracebacks, standard
logginginterception, FastAPI / Starlette middleware and canonical request events with tail sampling.
Requirements¶
Python 3.10+, on Linux, macOS or Windows. Pre-built wheels are published for all of them, so you don't need a Rust toolchain.
Installation¶
Example¶
Create it¶
Create a file main.py with:
from logust import logger
logger.info("Hello, Logust!")
logger.success("Connected to the database")
logger.warning("Disk usage is at {}%", 91)
logger.bind(user_id=42).error("Payment failed")
Run it¶
$ python main.py
<font color="#8A8A8A">2026-10-06 11:56:11.907</font> | <font color="#4E9A06"><b>INFO </b></font> | <font color="#06989A">__main__</font>:<font color="#06989A"><module></font>:<font color="#06989A">3</font> - Hello, Logust!
<font color="#8A8A8A">2026-10-06 11:56:11.908</font> | <font color="#8AE234"><b>SUCCESS </b></font> | <font color="#06989A">__main__</font>:<font color="#06989A"><module></font>:<font color="#06989A">4</font> - Connected to the database
<font color="#8A8A8A">2026-10-06 11:56:11.908</font> | <font color="#C4A000"><b>WARNING </b></font> | <font color="#06989A">__main__</font>:<font color="#06989A"><module></font>:<font color="#06989A">5</font> - Disk usage is at 91%
<font color="#8A8A8A">2026-10-06 11:56:11.908</font> | <font color="#CC0000"><b>ERROR </b></font> | <font color="#06989A">__main__</font>:<font color="#06989A"><module></font>:<font color="#06989A">6</font> - Payment failed
You didn't configure anything, and you already have:
- A timestamp with milliseconds.
- A colored, aligned level.
- The module, function and line that logged the message.
- loguru-style
{}formatting for message arguments. - Context attached with
bind(), ready to show up in your format or in JSON output.
Example upgrade¶
Now let's take it to production. Add a file sink that rotates at 500 MB, keeps 30 days of logs, compresses old files, writes JSON, and does the writing in a background thread:
from logust import logger
logger.add(
"app.log",
level="INFO",
rotation="500 MB",
retention="30 days",
compression=True,
serialize=True,
enqueue=True,
)
logger.bind(user_id=42).info("User logged in")
logger.complete()
Every line in app.log is now a JSON object:
{"time":"2026-10-06 11:56:11.944","level":"INFO","message":"User logged in","name":"__main__","function":"<module>","line":13,"extra":{"user_id":42}}
Recap¶
In summary, you import the logger and log. That's it. 🎉
When you need more, everything is a keyword argument on logger.add(): the level, the format, rotation, retention, compression, serialize for JSON, enqueue for background writes, filter, and more.
For a more complete example including more features, see the Tutorial - User Guide.
Spoiler alert: the tutorial - user guide includes:
- Log levels, and how to choose the minimum level.
- Message arguments with
{}placeholders. - Handlers and sinks: console, files and any Python callable.
- Log rotation, retention and compression.
- Custom formats with color markup.
- JSON output for log aggregators.
- Context with
bind()andcontextualize(). - Logging exceptions with full tracebacks, and the
@logger.catch()decorator. - Filters per handler.
Performance¶
Writing 10,000 messages to a file (release build, lower is better):
| Scenario | logging | loguru | logust |
|---|---|---|---|
| File write (sync) | 963.57 ms | 2676.74 ms | 15.93 ms |
| Formatted messages | 966.38 ms | 2710.67 ms | 15.65 ms |
| JSON serialize | N/A | 2717.99 ms | 14.91 ms |
| With context (sync) | N/A | 2600.08 ms | 14.29 ms |
| File write (async + complete) | N/A | 3019.49 ms | 16.50 ms |
To learn more about it, see the section Benchmarks.
Optional Dependencies¶
Logust has no required dependencies. Some integrations are installed with extras:
logust[fastapi]: the request logging middleware for FastAPI.logust[starlette]: the same middleware for plain Starlette.
License¶
This project is licensed under the terms of the MIT license.