空港防疫算法交互
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
988B

  1. # -*- coding: utf-8 -*-
  2. import sys
  3. import os
  4. from loguru import logger
  5. # 初始化日志配置
  6. def init_log(content):
  7. if not os.path.exists(content["log"]["base_path"]):
  8. os.makedirs(content["log"]["base_path"])
  9. # 移除日志设置
  10. logger.remove(handler_id=None)
  11. # 打印日志到文件
  12. if content["log"]["enable_file_log"]:
  13. logger.add(content["log"]["base_path"] + content["log"]["log_name"],
  14. rotation=content["log"]["rotation"],
  15. retention=content["log"]["retention"],
  16. format=content["log"]["log_fmt"],
  17. level=content["log"]["level"],
  18. enqueue=content["log"]["enqueue"],
  19. encoding=content["log"]["encoding"])
  20. # 控制台输出
  21. if content["log"]["enable_stderr"]:
  22. logger.add(sys.stderr,
  23. format=content["log"]["log_fmt"],
  24. level=content["log"]["level"],
  25. enqueue=True)