summaryrefslogtreecommitdiff
path: root/misc/factoralLog.py
blob: c0824230f1afd1251e63960df5a7d64e93f51ffa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!python3

# Chapter 10 Factoral Log

import logging
logging.basicConfig(filename='errorLog.txt', level=logging.DEBUG, format=' %(asctime)s - %(levelname)s - %(message)s')
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 ' + str(i) + ', total is ' + str(total))
    logging.debug('End of Factorial(%s%%)' % (n))
    return total

print(factorial(5))
logging.debug('End of Program')