파이썬 프로그래밍으로 지루한 작업 자동화하기 학습중..



import logging
# logging.basicConfig(level = logging.DEBUG, format = '%(asctime)s s %(levelname)s - %(message)s')
# logging.basicConfig(filename = 'myPGMlog.txt', level = logging.INFO, format = '%(asctime)s s %(levelname)s - %(message)s')
logging.basicConfig(filename = 'myPGMlog.txt', level = logging.DEBUG, format = '%(asctime)s s %(levelname)s - %(message)s')
logging.debug('Start of program')
# logging.disable(logging.CRITICAL) ## logging on/off 명령어

def factorial(n) :
logging.debug('Start of factorial(%s%%)' %(n))
total = 1
for i in range(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')

## 수준 로깅 함수 설명
## DEBUG logging.debug() 가장 낮은 수준이다. 사소한 세부 사항에 사용된다. 보통은 문제를 진달할 때만 이러한 메시지에 관심있을 것이다.
## INFO logging.info() 프로그램의 일반적인 이벤트에 관한 정보를 기록하거나 프로그램이 그 지점에서 제대로 동작하는지 확인하기 위해 사용된다.
## WARNING logging.warning() 프로그램의 동작까지는 막지 않지만 앞으로 그럴 가능성이 있는 문제를 가리키는데 사용된다.
## ERROR logging.error() 프로그램이 무엇인가 실패한 원인이 된 오류를 기록하는데 사용된다.
## CRITICAL logging.critical 가장 높은 수준의 로깅함수로 프로그램의 실행을 완전히 중단시킨 원인이 되었거다 원인이 되려하는 치명적인 오류를 표시하는데 사용

logging.basicConfig(level = logging.INFO, format = '%(asctime)s s %(levelname)s - %(message)s')
logging.critical('Critical error! Critical error!')
# logging.disable(logging.CRITICAL)
logging.error('Error~ Error~')



+ Recent posts