#!/usr/bin/python
import logging
logging.basicConfig(filename='example.log',level=logging.INFO,format='%(asctime)s %(levelname)s:%(message)s')
logging.debug('This message should go to the log file')
logging.info('So should this')
logging.warning('And this, too')
def setupLogging():
    
# create logger
    logger = logging.getLogger(__name__)
    logger.setLevel(logging.DEBUG)

# create console handler and set level to debug
    ch = logging.FileHandler('testFile.log')
    ch.setLevel(logging.DEBUG)

# create formatter
    formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')

# add formatter to ch
    ch.setFormatter(formatter)

# add ch to logger
    logger.addHandler(ch)

# 'application' code
    logger.debug('debug message')
    logger.info('info message')
    logger.warn('warn message')
    logger.error('error message')
    logger.critical('critical message')

setupLogging()

def abstraction():
    setupLogging()

abstraction()
