Logging
The Python logging module is one of those modules that are extremely useful, but it tends to be very difficult to use correctly. The result is often that people just disable logging completely and use print statements instead. This is insightful but a waste of the very extensive logging system in Python. If you've written Java code before, you might be familiar with the Log4j Java library. The Python logging module is largely and primarily based on that library.
The most important objects of the logging module are the following:
- Logger: the actual logging interface
- Handler: This processes the log statements and outputs them
- Formatter: This formats the input data into a string
- Filter: This allows filtering of certain messages
Within these objects, you can set the logging levels to one of the default levels:
CRITICAL: 50
ERROR: 40
WARNING: 30
INFO: 20
DEBUG: 10
NOTSET: 0
The numbers are the numeric values of these log levels. While you can generally ignore them, the order is obviously important...