Logging is a very powerful way of validating your program executes correctly. In addition you can use it to debug your program.

You can log a process in your program using the module logging.

Online Courses

This message would be shown in the terminal.

Levels of severity
There are several levels of severity: DEBUG, INFO, WARNING, ERROR, CRITICAL.
You can configure a minimum level of severity, if it’s lower than the set level it’s ignored.

Another example:

While developing you could set the severity level to logging.DEBUG which will show all messages. This will help you develop faster, find bugs quicker and so on.

Upon release of your program to the market you could set it to debugging.WARNING or debugging.ERROR.

Previous Post
Next Post

Leave a Reply