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\USER\lzx\01算法开发\02析锂检测\01下载数据\\'+self.name, level=Level,format='%(asctime)s - %(levelname)s - %(message)s') def logopt(self,*info): logging.error(info) logging.error(traceback.format_exc())