You know when you have coded your biggest project and every time it runs you can barely figure out what is doing, only by reading a series of print statements and the creation of strategically saved files?
Well if that is the case, you ought to learn logging and step up your game.
With a proper system of logging. you will have a consistent, ordered and a more reliable way to understand your own code, to time and track its progression and capture bugs easily.
Let’s break down the advantages of logging:
- Formatting: Logging allows you to standardize every message using a format of your choosing.
- Time tracking: Alongside the message you can add the time when it is generated.
- Compact: All messages are gathered in files, you don’t need to scroll up continuously.
- Versatility: Print does not work everywhere (i.e., objects without __str__ methods).
- Flexibility: Logging allows different levels of importance to your messages so you regulate what to show.
With all of this, you won’t be the only one who can understand your code.
Let’s start!Continue reading “Logging in Python”