|
|
|
|
|
by connorbrinton
1455 days ago
|
|
Another great project for Python logging is loguru:
https://loguru.readthedocs.io/en/stable/overview.html One of my favorite features of loguru is the ability to contextualize logging messages using a context manager. with logger.contextualize(user_name=user_name):
handle_request(...)
Within the context manager, all loguru logging messages include the contextual information. This is especially nice when used in combination with loguru's native JSON formatting support and a JSON-compatible log archiving system.One downside of loguru is that it doesn't include messages from Python's standard logging system, but it can be integrated as a logging handler for the standard logging system. At the company where I work we've created a helper similar to Datadog's ddtrace-run executable to automatically set up these integrations and log message formatting with loguru |
|
I'll never go back to that rancid pile of shit that is the builtin logger lib.