python 日志

 


def initial_log(self, fileName, logName, level=logging.INFO, fileSize=1024):
    handler = RotatingFileHandler(fileName + '.log', maxBytes=1 * fileSize * 1024, backupCount=5)
    formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
    handler.setFormatter(formatter)
    self.logger = logging.getLogger(logName)
    self.logger.setLevel(level)
    self.logger.addHandler(handler)

posted @ 2023-08-30 21:24  Orientation  阅读(7)  评论(0编辑  收藏  举报