import logging import traceback class Mylog: def __init__(self,log_name,log_level): self.name=log_name self.level=log_level def logcfg(self): if len(self.level) > 0: if self.level == 'debug': Level=logging.DEBUG elif self.level == 'info': Level=logging.INFO elif self.level == 'warning': Level=logging.WARNING else: Level=logging.ERROR logging.basicConfig(filename=r'D:\Work\Code_write\data_analyze_platform\test\lzx\01Qixiang\01电压排序\01算法\\'+self.name, level=Level,format='%(asctime)s - %(levelname)s - %(message)s') def logopt(self,*info): logging.error(info) logging.error(traceback.format_exc())