Table of Contents
Last Updated on 2023-10-21 by Kassandra
Logging in python – does thinking about it it bring you anxiety?
Do you think of a ton of print statements?
If so, I’m about to blow your mind …
If you are not a pro with the built in logging module, you are not alone.
Although I got my Bachelor’s of Science in Computer Science, my college focused mainly on Java.
So basically? I’m a self taught pythonista. (i.e. python developer)
So when I see cool code like the ones shared here that help make development easier, I love sharing it with others!
What Is The Logging Facility In Python?
It was maybe a year into developing with python that I first heard about the logging facility in python. And I thought it was just the NEATEST thing!
Here are just a few things it can do:
- Pre-configure your formatting and where you want logs to go
- Handle multi-threading & even across modules
- Send logging messages to console and files – and have them use different levels
- Send over the network (for DevOps and network administration)
- Easily handle multiple files being created (e.g. limit size, number of files, etc)
But I had to keep building it every time I wanted to use the structure.
… until now!
Logging In Python Helper Script
I did a live video walkthrough of the code. You can watch the replay below:
Looking for the code? You can check out the logging in python code I have here in my GitHub.
I am currently considering refining it even more so it’s a class that can be imported, but that may be overkill. We’ll see once I get feedback from other developers.
Thank you for spending your time here with me today!