Prettify Your Python Logs with Loguru
How an easy-to-use logger can format your log data output.
Note: The following is an objective evaluation of a Python library. I am not associated with nor do I receive any form of compensation from any entity associated with Loguru.
If you’re a data engineer, chances are, you will likely agree with two fundamental truths I’ve discovered about our craft:
- No matter how perfect you make something, it will break at least once.
- Logs are ugly.
Whether writing or interpreting logs locally or on cloud infrastructure, the output is, admittedly, difficult to interpret, especially if you are in a situation where you are diagnosing an error on a system you’re unfamiliar with.
Even if you strategically place logging statements throughout your code, the output will still be blocks of unformatted, dizzying metadata.
Parsing raw data is fine and part of the job. I regularly deal with raw JSON and other messy outputs.
But when that data contains critical information about your infrastructure, it needs to be communicated as clearly, as legibly and as quickly as possible.
There are ways to cleanly format JSON data; there are even platforms that will convert…