opencv_webcam/utils/log.py

22 lines
634 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.

# OpenCV Webcam Script v0.3
# 创建人:曾逸夫
# 创建时间2022-01-14
import sys
# 检查日志格式
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):
ROOT_PATH = sys.path[0] # 项目根目录
logFile = open(f'{ROOT_PATH}/{logName}', logSaveMode) # 日志文件
logFile.write(logContent) # 日志写入