[ Python ] custom logging level 만들기
2019. 9. 11. 20:21ㆍ분석 Python/구현 및 자료
728x90
logging level 추가하기.
import logging
trace = 15
class user(logging.Logger) :
def trace(self , msg , *args ,**kwargs ):
self.log( trace ,msg , *args ,**kwargs )
logging.setLoggerClass(user)
logging.addLevelName(15 , "user")
logger = logging.getLogger("test")
logger.setLevel("user")
ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG)
logger.addHandler(ch)
logger.debug(" debug test")
logger.trace("custom test")
logger.info("info test")
728x90
'분석 Python > 구현 및 자료' 카테고리의 다른 글
__pycache__ 폴더 제거하는 방법 (0) | 2019.09.20 |
---|---|
[ Python ] 새로 만든 함수 수정 후 restart 안하고 reload하기 (0) | 2019.09.18 |
[ Python ] imputation algorithm package 정리 (2) | 2019.09.10 |
[ Python ] How to fast String to pandas data frame 연습 (0) | 2019.09.04 |
[ Python ] logging 만들어보기 (FileHandler 와 StreamHandler 위주로) (0) | 2019.08.25 |