Essays written on the already read the package Excel class, the following write log category,
Log category in our automated process is very important, when in our automation program to exhibit unusual in the log can be printed
Here is my own package for the log
import logging import os from request_test.config.project_path import Path class MyLogger(logging.Logger): def __init__(self, name, hander_lever="DEBUG", level="DEBUG", file_name=None, fmt="%(filename)s--%(asctime)s--%(lineno)d--%(message)s"): . Super () the __init__ (name, Level = Level) # file is determined whether the transmission log storage initialization processor (hander) IF file_name IS Not None: hander = logging.FileHandler(file_name, encoding="utf-8") else: hander = logging.StreamHandler () # adding hander self.addHandler (hander) # Set the processor level hander.setLevel (hander_lever) # Set fmt format: log display style file_fmt = logging.Formatter (fmt) hander.setFormatter(file_fmt) logger = MyLogger(name="Lc", file_name=os.path.join(Path().LOG_PATH, "log.log"))
Under can own debugging, the debugging process is as follows:
if __name__ == '__main__':
logger.error("hahahha")