"""
日志模块的使用
"""
import logging
# 加上filename,日志会输出到文件里
logging.basicConfig(filename='myProgramLog.txt', level=logging.DEBUG, format=' %(asctime)s - %(levelname)s - %(message)s')
# 禁用INFO及更低级别的日志
# logging.disable(level=logging.INFO)
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')