log.py 802 B

123456789101112131415161718192021222324
  1. import logging
  2. import traceback
  3. class Mylog:
  4. def __init__(self,log_name,log_level):
  5. self.name=log_name
  6. self.level=log_level
  7. def logcfg(self):
  8. if len(self.level) > 0:
  9. if self.level == 'debug':
  10. Level=logging.DEBUG
  11. elif self.level == 'info':
  12. Level=logging.INFO
  13. elif self.level == 'warning':
  14. Level=logging.WARNING
  15. else:
  16. Level=logging.ERROR
  17. logging.basicConfig(filename=r'D:\Develop\User\Liuzhongxiao\data_analyze_platform\USER\01算法开发\02析锂检测\liplated\\'+self.name, level=Level,format='%(asctime)s - %(levelname)s - %(message)s')
  18. def logopt(self,*info):
  19. logging.error(info)
  20. logging.error(traceback.format_exc())