diff --git a/Git.md b/Git.md index 1e8a073f..0f8d3d3f 100644 --- a/Git.md +++ b/Git.md @@ -39,8 +39,6 @@ 参考链接: https://blog.csdn.net/u013778905/article/details/83501204 ``` - - # 问题描述 ```bash Push failed diff --git a/gitee/day07/car.py b/gitee/day07/car.py index a8c34edc..b123395d 100644 --- a/gitee/day07/car.py +++ b/gitee/day07/car.py @@ -121,11 +121,8 @@ def transform(img, point_set_0, point_set_1): def main(): -<<<<<<< HEAD path = os.getcwd()+"\\img\\3.jpg" -======= path = os.getcwd()+"\\img\\0.jpg" ->>>>>>> python-day # 图像预处理 img, img_Gas, img_B, img_G, img_R, img_gray, img_HSV = imgProcess(path) # 初步识别 diff --git a/gitee/day07/log/LogUtil.py b/gitee/day07/log/LogUtil.py new file mode 100644 index 00000000..2ad0aa8c --- /dev/null +++ b/gitee/day07/log/LogUtil.py @@ -0,0 +1,44 @@ +import logging +from logging import handlers + + +class Logger(object): + # 日志映射级别关系 + level_relations = { + 'debug': logging.DEBUG, + 'info': logging.INFO, + 'warning': logging.WARNING, + 'error': logging.ERROR, + 'crit': logging.CRITICAL + } + + def __init__(self, filename, level='info', when='D', backCount=3, + fmt='%(asctime)s - %(pathname)s[line:%(lineno)d] - %(levelname)s: %(message)s'): + self.logger = logging.getLogger(filename) + formatter_str = logging.Formatter(fmt) # 设置日志格式 + self.logger.setLevel(self.level_relations.get(level)) # 设置日志级别 + sh = logging.StreamHandler() # 往屏幕上输出 + sh.setFormatter(formatter_str) # 设置屏幕上显示的格式 + # 往文件里写入 指定间隔时间自动生成文件的处理器 + th = handlers.TimedRotatingFileHandler(filename=filename, when=when, backupCount=backCount, encoding='utf-8') + # 实例化TimedRotatingFileHandler + # interval是时间间隔,backupCount是备份文件的个数,如果超过这个个数,就会自动删除,when是间隔的时间单位,单位有以下几种: + # S 秒 + # M 分 + # H 小时、 + # D 天、 + # W 每星期(interval==0时代表星期一) + # midnight 每天凌晨 + th.setFormatter(formatter_str) # 设置文件里写入的格式 + self.logger.addHandler(sh) # 把对象加到logger里 + self.logger.addHandler(th) + + +if __name__ == '__main__': + log = Logger('all.log', level='debug') + log.logger.debug('debug') + log.logger.info('info') + log.logger.warning('警告') + log.logger.error('报错') + log.logger.critical('严重') + Logger('error.log', level='error').logger.error('error') diff --git a/gitee/day07/log/error.log b/gitee/day07/log/error.log new file mode 100644 index 00000000..e69de29b diff --git a/python_json/python_json b/python_json/python_json new file mode 160000 index 00000000..8992e63f --- /dev/null +++ b/python_json/python_json @@ -0,0 +1 @@ +Subproject commit 8992e63f8f4204dafab90be12d978c5865d65b12