How To - Recipes¶
Here you will find different recipes or "how to" guides for specific problems.
Most of these ideas are more or less independent, and in most cases you only need to read them if the problem applies directly to your project.
If something here looks interesting and useful for your project, go ahead and check it, but otherwise, you can probably just skip them.
Tip
If you want to learn Logust in a structured way (recommended), go and read the Tutorial - User Guide chapter by chapter instead.
The recipes¶
- Intercept Standard Logging: send everything logged with the standard
loggingmodule, including the logs of third-party libraries, through Logust. - FastAPI and Starlette: log every request with timing and request IDs, mask sensitive data, or emit one canonical event per request.
- Function Timing Decorators: log how long a function takes with
@log_fnand@debug_fn. - Progress Bars: log above a
richortqdmprogress bar without breaking it. - Migrate from loguru: what changes, and what doesn't, when you swap
logurufor Logust. - Migrate from logging: how the standard
loggingconcepts map to Logust.
Optional dependencies¶
The helpers in logust.contrib that these recipes use don't need anything beyond Logust itself, except the FastAPI / Starlette middleware. For it, install one of the extras:
The progress bar recipe uses rich or tqdm, which you install as usual if you don't have them already.