Q: "How do you handle logs? I am looking for tools to better format my logs and maybe process and filter them"
- The call to basicConfig() should come before any calls to debug(), info() etc. As it’s intended as a one-off simple configuration facility, only the first call will actually do anything: subsequent calls are effectively no-ops.
On error handling:
The logging package is designed to swallow exceptions which occur while logging in production.
This is so that errors which occur while handling logging events - such as logging misconfiguration, network or
other similar errors - do not cause the application using logging to terminate prematurely
Source: https://docs.python.org/3/howto/logging.html#exceptions-raised-during-logging
If exc_info is not set to True, the output of the above program would not tell us anything about the exception,
which, in a real-world scenario, might not be as simple as a ZeroDivisionError.
Source: https://realpython.com/python-logging/#capturing-stack-traces
- My usage of
loggingand it working fine for years - Nice docs page https://docs.python.org/3/howto/logging.html
- Nice article https://realpython.com/python-logging/
- PEP https://www.python.org/dev/peps/pep-0282/