Last active
August 27, 2017 07:12
-
-
Save ShekharReddy4/ddd5a4e5858f8acc538b57bcb3f75960 to your computer and use it in GitHub Desktop.
Log utility example in python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Module that uses the custom logging module | |
""" | |
from LogUtility import Logger | |
Logger.log('examples.log', 'this is usinweg the logging module') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This example explains a simple logging module which could be used anywhere in a python project.
usage :
Logger.log(path, message)