Posts in June, 2020

I recently tested Rich logging with a Django project and the results were good. Here's what it looks like:

A Django app with Rich logging

Note the file and line at the right hand of the terminal which shows were the log function was called. If your terminal supports hyperlinks, you can click that link to open the file!

For reference, here's what it looks like without Rich logging.

A Django app without Rich logging

This is the default RichHandler class in Rich. It would be possible to do a little more customization for Django logs. Maybe highlight 5xx in red, for example.

To add this to your Django project, pip install rich then configure the console to use "rich.logging.RichHandler" rather than StreamHandler.