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=self.name, level=Level,format='%(asctime)s - %(levelname)s - %(message)s') def logopt(self,*info): logging.error(info) logging.error(traceback.format_exc())