xlog.py 875 B

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