xlog.py 861 B

12345678910111213141516171819202122232425262728
  1. # update: 2022-4-19
  2. import logging
  3. import traceback
  4. LOG = logging.getLogger(__name__)
  5. # logging.basicConfig(format='%(levelname)s | %(asctime)s | %(module)s.%(funcName)s:%(lineno)s >>> %(message)s',
  6. # level=logging.DEBUG)
  7. logging.basicConfig(format=f"INFO: %(message)s", level=logging.INFO)
  8. def debug_log(tags, args, is_work=True, show_level=logging.INFO):
  9. """"""
  10. if not is_work:
  11. return
  12. elif type(args) == list:
  13. lines = f"{tags}:"
  14. for count, line in enumerate(args):
  15. lines += f"\n- {count + 1} - {line}"
  16. LOG.info(lines)
  17. elif type(args) == str:
  18. now_string = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
  19. LOG.info(f"{now_string} | {tags} | {args}")
  20. # LOG.info(f"{tags} | {args}")
  21. def trace_log():
  22. """"""
  23. return traceback.format_exc()