Skip to content

Instantly share code, notes, and snippets.

@ShekharReddy4
Last active August 27, 2017 07:12
Show Gist options
  • Save ShekharReddy4/ddd5a4e5858f8acc538b57bcb3f75960 to your computer and use it in GitHub Desktop.
Save ShekharReddy4/ddd5a4e5858f8acc538b57bcb3f75960 to your computer and use it in GitHub Desktop.
Log utility example in python
"""
simple logging module
"""
import logging
class Logger(object):
"""
Logger class which is used to log the messages
"""
@classmethod
def log(cls, path, message):
"""
Log function which is used to log the messages to a specfied path
"""
logging.basicConfig(
level=logging.INFO,
filename=path,
format='%(asctime)s %(message)s',
datefmt='%m/%d/%Y %I:%M:%S %p')
logging.info(message)
"""
Module that uses the custom logging module
"""
from LogUtility import Logger
Logger.log('examples.log', 'this is usinweg the logging module')
@ShekharReddy4
Copy link
Author

ShekharReddy4 commented Aug 27, 2017

This example explains a simple logging module which could be used anywhere in a python project.
usage : Logger.log(path, message)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment