Python Easy Logging

Imran Ali
2 min readAug 1, 2021

--

A programmer being happy using python easy logger

Do you have a multi-modular python application and want to swiftly enable logging in it?
Are you tired of Initializing logger in your every module and keeping track of it ?
Is your Python logger not working as it is supposed to ?
Do you want different kind of logging happening together with minimal code ?
Do you want to quickly enable logging into your code before wrapping up your progress today ?

If the answer is ‘YES’ to any of the question above then you have come to the right place.

I have written an easy to implement wrapper for you that prevents you from scratching your head for the PETTY yet ANNOYING logging issues that you might encounter.

Let’s Get Started !

Installation

You need to download 2 files from the GitHub repository attached below and place it in your current working folder.
Files : [ Logger.py ] with the config [ logging.conf ]
Link : https://github.com/m-imranali/Python-Easy-Logger

Usage

Import the Easy-Logger Wrapper into your Script/Module

import Logger

Then initialize it in the main indent

logger = Logger.Logger("Main Program")

And that’s all. Now you can log your heart out throughout your module using :

logger.debug("Nice My Debug Log Message")
logger.info("Ok My Info Log Message")
logger.warning("Hmm My Warning Log Message")
logger.error("Oops My Error Log Message")
logger.critical("Eeehhh My Critical Log Message")

Advanced Usage

There are two level of details in the Easy-Logger at the moment

  • root
  • brief

The level can be changed easily when initializing the module by using the following command

logger = Logger.Logger("Main Program",'brief')

logger = Logger.Logger("Main Program",'root')

Yet To Come..

  • Example Code
  • More level of details handlers in the Easy-Logger
  • Details about modifying the configuration file
  • Logs rotation details
  • Network Logging
  • More Log Formats

First of many stories & tutorials to come.. Still getting familiar with the medium and its interface though 😆.
Hopefully these will prove worthwhile to the community.

--

--

Imran Ali
Imran Ali

Written by Imran Ali

0 Followers

Hi, I’m a Python developer at heart, working on both frontend and backend. I would love to have your feedback on my work to learn more and provide more. Cheers

No responses yet