您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

20 行
755B

  1. import logging
  2. import sys
  3. def _get_logger():
  4. log = logging.getLogger('log')
  5. log.setLevel(logging.INFO)
  6. console_handle = logging.StreamHandler(sys.stdout)
  7. console_handle.setFormatter(logging.Formatter('[%(levelname)s][%(asctime)s][%(filename)s:%(lineno)d] - %(message)s',
  8. datefmt='%Y-%m-%d %H:%M:%S'))
  9. file_handle = logging.FileHandler('run.log', encoding='utf-8')
  10. file_handle.setFormatter(logging.Formatter('[%(levelname)s][%(asctime)s][%(filename)s:%(lineno)d] - %(message)s',
  11. datefmt='%Y-%m-%d %H:%M:%S'))
  12. log.addHandler(file_handle)
  13. log.addHandler(console_handle)
  14. return log
  15. # 日志句柄
  16. logger = _get_logger()