Configuring different debug output levels
In this recipe, we will configure different debug levels that we can select and change at runtime. This allows us to control how much we want to drill down into our code when debugging our code.
We will create two new Python classes and place both of them into the same module.
We will use four different logging levels and we will write our debugging output to a log file we will create. If the log folder does not exist, we will create it automatically as well.
The name of the log file is the name of the executing script which is our refactored GUI.py
. We can also choose other names for our log files by passing in the full path to the initializer of our logger class.
Getting ready
We will continue to use our refactored GUI.py
code from the previous recipe.
How to do it...
First, we create a new Python module into which we place two new classes
. The first class
is very simple and defines the logging levels. This is basically an enumeration
.
class LogLevel:...