🚀 From print() to Proper Logging in Python While building backend systems and data pipelines, I recently made a small but important improvement in my code. Instead of using print() statements for debugging and tracking execution, I switched to a proper logging system using Python’s built-in logging module. Here’s what I implemented: ✅ Created a reusable get_logger() function ✅ Logs are saved to a file (logs/pipeline.log) ✅ Logs also appear in the console for real-time monitoring ✅ Added structured log format with timestamp, module name, level, and message Why this is better than print(): Helps track issues in production environments Keeps a history of application events Makes debugging easier in complex systems Provides structured and readable logs This small change makes backend applications much more production-ready and maintainable. One thing I’ve learned while building backend systems: Good logging is as important as good code. Do you still use print() for debugging or have you fully switched to logging? #Python #BackendDevelopment #Logging #SoftwareEngineering #CleanCode #PythonTips
Improving Backend Logging with Python's Built-in Logging Module
More Relevant Posts
-
Want good code? Let the 𝐢𝐦𝐩𝐥𝐞𝐦𝐞𝐧𝐭𝐚𝐭𝐢𝐨𝐧 𝐟𝐨𝐥𝐥𝐨𝐰 𝐫𝐮𝐥𝐞𝐬 ⚙️ There are two ways of doing that in Python: with either 𝐀𝐁𝐂 𝐈𝐧𝐭𝐞𝐫𝐟𝐚𝐜𝐞𝐬 or with 𝐏𝐫𝐨𝐭𝐨𝐜𝐨𝐥𝐬. 𝐀𝐁𝐂 𝐈𝐧𝐭𝐞𝐫𝐟𝐚𝐜𝐞𝐬 is when you (1) write a base class with methods, (2) let implementations 𝑖𝑛ℎ𝑒𝑟𝑖𝑡 from that class and 𝑓𝑜𝑟𝑐𝑒 𝑡ℎ𝑒𝑚 𝑡𝑜 𝑖𝑚𝑝𝑙𝑒𝑚𝑒𝑛𝑡 all the required methods. This way you catch errors early, but it may require more code. 🧱 𝐏𝐫𝐨𝐭𝐨𝐜𝐨𝐥𝐬 are when you (1) write a protocol class, and (2) during use 𝑎𝑐𝑐𝑒𝑝𝑡 𝑎𝑛𝑦 𝑐𝑙𝑎𝑠𝑠 𝑡ℎ𝑎𝑡 ℎ𝑎𝑠 𝑡ℎ𝑒 𝑠𝑎𝑚𝑒 𝑚𝑒𝑡ℎ𝑜𝑑𝑠 as defined in the protocol. This gives you flexibility to plug-and-play quickly. Less code, but errors may only appear at runtime. 🧩 𝐆𝐞𝐧𝐞𝐫𝐚𝐥 𝐫𝐮𝐥𝐞: - Protocols are good for 𝘦𝘹𝘵𝘦𝘳𝘯𝘢𝘭 𝘴𝘵𝘶𝘧𝘧 like APIs, LLM providers, data sources 🌍 - Interfaces are good for 𝘪𝘯𝘵𝘦𝘳𝘯𝘢𝘭 𝘴𝘵𝘶𝘧𝘧 like core logic of your system ⚙️ 𝐹𝑙𝑒𝑥𝑖𝑏𝑙𝑒 𝑎𝑡 𝑡ℎ𝑒 𝑒𝑑𝑔𝑒𝑠, 𝑠𝑡𝑟𝑖𝑐𝑡 𝑎𝑡 𝑡ℎ𝑒 𝑐𝑜𝑟𝑒. #software #engineering #best #practices
To view or add a comment, sign in
-
-
Python Virtual Environments: What I Wish I Knew Earlier Just set up my first production-ready development environment, and here's why venv is non-negotiable: Before venv ❌ → One Python installation → Package version conflicts → Projects breaking randomly → Dependency nightmare After venv ✅ → Isolated environments per project → Zero conflicts → Team-ready code → Professional workflow The Command That Changes Everything: python -m venv venv venv\Scripts\activate Current Project: Building an AI Book Builder SaaS Stack: Python | FastAPI | Clean Architecture Are you using virtual environments in your Python projects? Drop a ✅ if yes!
To view or add a comment, sign in
-
Alex Marin, our application packaging expert, just published a personal story on his early days in endpoint management. It was so good that it was accepted on the reputable Level Up Coding on Medium.com. Long story short: a "simple" Python script turned into a total production nightmare. And how software deployment fails at scale. “The culprit wasn’t a server outage or a complete network failure. It was a Python script! A small one. One that you might consider as harmless. The type of script that works flawlessly on one machine, then ten, then one hundred. But that morning, it had to run on thousands of machines. That’s when everything fell apart…” Check out the full story on how he turned it around: https://lnkd.in/dB8pN_By #Python #EndpointManagement #TechLessons #SoftwareEngineering #DevOps
To view or add a comment, sign in
-
Python. Concurrency. Clean Design. How do you keep Python code clean and maintainable when it processes massive volumes of financial data every day? Delivered a Clean Code Python program for a technology team at a leading financial organization (9–12 March 2026). The sessions focused on writing Python that remains composable, testable, and scalable in data-intensive systems. Topics included: • Coding against contracts using Protocols and ABCs • Functional patterns — closures, generators, decorators, lambdas, functors • Expressive OOPs modelling with dataclasses and slots • Practical design patterns — Singleton, Adapter, Decorator, Strategy, Observer • Concurrency in Python — async/await, threads, and locks & conditions • Building reliable systems with Test-Driven Development (TDD) Always energizing to work with teams tackling large-scale data systems while striving for clarity and craftsmanship in code. #Python #CleanCode #Concurrency #DesignPatterns #TDD #SoftwareEngineering
To view or add a comment, sign in
-
-
Most Python developers use print() every day — but very few know ALL its parameters. 🐍 Here's everything packed into one cheat sheet: ✅ Basic syntax: print(*objects, sep=' ', end='\n', file=sys.stdout, flush=False) ✅ 5 parameters you should know: → sep — change the separator between values → end — control what prints at the end (not always a newline!) → file — print directly to a file or stream → flush — force immediate output (useful in logs & pipelines) → f-strings — the cleanest way to format output ✅ Common mistakes to avoid: ❌ Forgetting quotes around text ❌ Missing commas between multiple values ❌ Concatenating strings + numbers directly ❌ Forgetting parentheses (Python 2 habit!) Whether you're debugging, logging, or formatting output — mastering print() makes your code cleaner and you faster. 💡 Save this for your next coding session. 🔖 --- 📌 Follow for daily Python tips and developer resources. #Python #Programming #CodingTips #LearnPython #SoftwareDevelopment #PythonDeveloper #CodeNewbie #100DaysOfCode #TechEducation #Developer
To view or add a comment, sign in
-
-
I was tired of sending emails manually, so I created this email automation system that can send emails automatically to a number of recipients and helps reduce time. Built with Python, this tool reads recipients, subjects, and message templates from simple files, sends in controlled batches, supports multiple sender accounts, and logs sent emails to avoid duplicates. What used to take hours now takes minutes. Still improving it, this is version 1.0 #Python #Automation #EmailAutomation #Productivity #BuildInPublic #DeveloperJourney
To view or add a comment, sign in
-
🚀 Leverage Python for Essential SD-WAN Operational Commands Manual network audits are a significant bottleneck. This visual guide provides a direct and useful roadmap for automating critical SD-WAN operations with Python. On the left, you'll find a clear Python script example using popular libraries like requests and ConnectHandler (from netmiko) to connect to the vManage API. On the right, it lists the essential SD-WAN 'show' commands you should be automating right now for comprehensive visibility: Control Plane Status (show sdwan control connections) Data Plane Performance (show sdwan bfd sessions) System Health & Inventory OMP Routing & Policies The end goal is simple: Turning raw API data into Actionable Insights (reports, dashboards) to achieve better accuracy and massive time savings. If you’re looking for practical code and commands to automate your SD-WAN environment, this guide is a great resource. Save this image to help build your automation playbooks! #NetworkAutomation #SDWAN #PythonNetworking #CiscoNetworking #ITOps #NetworkEngineering #vManage
To view or add a comment, sign in
-
-
🚀 Day 8 of my Python Automation Journey Today I built an Email Automation script using Python. Using Python's smtplib module, the script can automatically send emails. Example use cases: • Sending automated notifications • Sending reports • Email reminders My GitHub repository now contains 8 Python automation projects: • Word Counter • File Renamer • Password Generator • Web Scraper • CSV Data Cleaner • File Organizer • System Monitor • Email Automation Learning Python step by step by building small automation projects every day. #Python #Automation #PythonProjects #CodingJourney #LearningInPublic
To view or add a comment, sign in
-
-
Pydantic is a Python library that helps you: 👉 Validate data automatically 👉 Convert data types safely 👉 Define clear data structures Before Pydantic, these were the problems: - You forget validation → bugs - Wrong types → crashes - Messy code everywhere With Pydantic: - Converts "25" → 25 - Validates data - Throws error if invalid Pydantic is heavily used in: - APIs → with FastAPI - Data pipelines - Backend systems - Config validation These are some of the advantages of Pydantic. #Python #Pydantic #datavalidation #LLMs
To view or add a comment, sign in
-
Better tools. Better code. Less stress. I shared 7 Python libraries that completely changed how I build automation projects. Check out the full article on my Medium account. Medium:@talhaulfat93
To view or add a comment, sign in
Explore related topics
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development