logging.py 296 B

123456789101112
  1. import logging
  2. logger = logging.getLogger()
  3. logger.setLevel(logging.INFO)
  4. ch = logging.StreamHandler()
  5. formatter = logging.Formatter(
  6. "%(asctime)s| \"%(pathname)s\", line %(lineno)d,\n %(levelname)s: %(message)s"
  7. )
  8. ch.setFormatter(formatter)
  9. logger.addHandler(ch) #将日志输出至屏幕