Skip to content

Instantly share code, notes, and snippets.

View fanhang64's full-sized avatar
🎯
Focusing

fanhang64

🎯
Focusing
View GitHub Profile
@fanhang64
fanhang64 / aa.py
Created September 3, 2019 09:21
logging源码实现
# logger.info('This is an info message')
# Logger().info() --> ._log() 然后 -> .makeRecord() # makeRecord 生成LogRecord对象,就是一条日志记录的对象
# 然后调用 Logger().handle(record) ---> .callHandlers(record) 里面循环执行 hdlr.handle(record), 这个hdlr 就是MidnightRotatingFileHandler对象,
# 找MidnightRotatingFileHandler的 父类 handle方法的实现,一直找到Handler类里的下面这个
# def handle(self, record):
# """
# Conditionally emit the specified logging record.
# Emission depends on filters which may have been added to the handler.
import logging
from logging.handlers import TimedRotatingFileHandler
from flask import Flask
# f_formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(filename)s - %(message)s')
fmt = '%(asctime)s - %(levelname)s - %(filename)s - %(message)s'
f_handler = TimedRotatingFileHandler('app.log', when='s', interval=1)
def creat_images_path(video_path, img_path): # aa/
carID_folder_list = os.listdir(video_path)
for carid in carID_folder_list:
carid_path = os.path.join(video_path, carid) # aa/123 aa/456
rootdir_folder_list = os.listdir(carid_path)
rootdir_folder_list.sort()
for camdir in rootdir_folder_list:
if camdir in cam_dict:
file_count = 0
dirpath = carid_path + '/' + camdir