Advanced User Guide¶
Additional Features¶
The main Tutorial - User Guide should be enough to give you a tour through all the main features of Logust.
In the next sections you will see other options, configurations, and additional features.
Tip
The next sections are not necessarily "advanced".
And it's possible that for your use case, the solution is in one of them.
Read the Tutorial first¶
You could still use most of the features in Logust with the knowledge from the main Tutorial - User Guide.
And the next sections assume you already read it, and that you know those main ideas: levels, message arguments, sinks, files and rotation, formatting, JSON output, context with bind() and contextualize(), exceptions, and filters.
What's in this section¶
Each page is independent, so feel free to jump to the one you need:
- Custom Levels: create your own levels, with a color and an icon, and update the built-in ones.
- Records and patch(): everything a record holds, and how to change records before they are written.
- Per-message Options with opt(): lazy arguments, the current exception, the caller depth, and more, for one message.
- Callbacks: react to messages with the full record, for example to send errors to your monitoring.
- Logging in Libraries: keep a library quiet by default with
disable("mylib"), and turn it on withenable("mylib"). - Tracebacks: show the outer frames and the variable values, per handler or per message.
- Async Writes: write files from a background thread with
enqueue=True, andcomplete()at shutdown. - Sink Errors: decide what happens when a sink fails, with
catch=. - Threads and Processes: threads, multiprocessing,
fork(), and free-threaded Python. - Performance: what makes a log call expensive, and
CollectOptions. - Parsing Log Files: read your logs back as dicts with
parse()andparse_json(). - Canonical Events: one wide event per request, with tail sampling.
Info
Looking for recipes, like redirecting the standard logging module, setting up FastAPI, or migrating from loguru? Check the How To - Recipes. 🤓