#!/usr/bin/env python3

## required setup for loggin funcgion:
import logging

#logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s')
logging.basicConfig(filename='myProgramLog.txt', level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s') #if you want the error log goes to the file

#logging.disable(logging.CRITICAL) # this command to disable login
logging.debug('Start of program')

def factorial(n):
    logging.debug('Start of factorial(%s)'%(n))
    total = 1
    for i in range(1,n+1):
        total*=i
        logging.debug('i is %s,total is %s' %(i,total))
    logging.debug('Return value is %s' %(total))
    return total

print(factorial(5))

logging.debug('end of program')