opencv_webcam/utils/log.py

31 lines
828 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 日志管理
# 创建人:曾逸夫
# 创建时间2022-01-14
import sys
import re
ROOT_PATH = sys.path[0] # 项目根目录
# 检查日志格式
def is_logSuffix(logName):
suffixList = ['log', 'txt', 'data'] # 日志后缀列表
log_suffix = logName.split('.')[-1] # 获取日志后缀
if log_suffix not in suffixList:
# 判断日志是否符合格式
print(f'日志格式不正确!程序结束!')
sys.exit() # 结束程序
# 日志管理
def log_management(logContent, logName, logSaveMode):
logFile = open(f'{ROOT_PATH}/{logName}', logSaveMode) # 日志文件
logFile.write(logContent) # 日志写入
# 日期时间&帧数
def date_time_frames(date_time, frames):
f = open(f'{ROOT_PATH}/date_time_frames.csv', 'a')
f.write(f'{date_time},{frames}\n')