123456789101112131415161718192021222324 |
- 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析锂检测\03车辆分析\\'+self.name, level=Level,format='%(asctime)s - %(levelname)s - %(message)s')
- def logopt(self,*info):
- logging.error(info)
- logging.error(traceback.format_exc())
|