About¶
About Logust, its design, inspiration and more. 🤓
Why Logust exists¶
loguru made logging in Python pleasant: one logger, no boilerplate, nice output by default. But every message still goes through pure Python code for formatting, serialization and writing, and that cost adds up in services that log a lot.
The standard logging module is everywhere, but it needs a lot of setup, and it's not fast either.
Logust is the attempt to have both: the API you already like from loguru, and a hot path fast enough that you don't have to think about the cost of a log line.
The design¶
Logust has two layers:
- A Rust core (built with PyO3) that does the work for every message: level checks, formatting, color markup, JSON serialization, file writes, rotation, retention, compression and background writes.
- A thin Python layer with the loguru-style API:
logger.add(),bind(),contextualize(),opt(),catch(),patch(), filters and callbacks, plus the integrations inlogust.contrib.
Two ideas guide the implementation:
- Only collect what you use. Logust reads your formats when you add a handler. If no handler shows the caller, thread or process, it doesn't inspect the stack for them. See Performance.
- Safe defaults. For example, tracebacks don't include variable values unless you ask for them, because they can contain secrets. See Tracebacks.
In this section¶
- Alternatives and Comparison: Logust compared with loguru and the standard
loggingmodule, and when to choose each. - Benchmarks: the numbers, and how to reproduce them.