logging配置

 1 import logging
 2 logging.basicConfig(level=logging.WARNING,
 3                     format='%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s',
 4                     datefmt='%a, %d %b %Y %H:%M:%S')
 5 try:
 6     int(input('num >>'))
 7 except ValueError:
 8     logging.error('输入的值不是一个数字')
 9 
10 logging.debug('debug message')       # 低级别的 # 排错信息
11 logging.info('info message')            # 正常信息
12 logging.warning('warning message')      # 警告信息
13 logging.error('error message')          # 错误信息
14 logging.critical('critical message') # 高级别的 # 严重错误信息
basicConfig

相关文章: