Member-only story
Colored Logs for Python
Printing colored messages to the console

Logging is an essential part of developing applications and lead to quick debugging and a broader understanding of what’s going on in your app. In this easy and short article we’re going to make our console logs a bit clearer by adding some color. Let’s code!
Preparations
We first need to install a package
pip install coloredlogs
Also make sure you understand the basics of logging and how to add a handler to your log with the article below:
Step 1: create a logger
Nothing new here: we just create a logger
We use the getLogger method so that we don’t use the root logger.
Step 2: coloredlogs
Here we install coloredlogs on our logger.
The last line makes sure that coloredlogs doesn’t pass our log events to the root logger. This prevents that we log every event double.
Step 3: creating a colored formatter
We want to add some style to our console outputs. We’ll define that here