modify scripts
This commit is contained in:
@ -37,8 +37,8 @@ map_books = {
|
|||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
#books = [2689, 3727, 4698, 5446]
|
#books = [2689, 3727, 4698, 5446]
|
||||||
#books = [3167, 2985, 3098]
|
#books = [3167, 2985, 3098]
|
||||||
books = [2783]
|
#books = [2783]
|
||||||
for book in books:
|
for book, name in map_books.items():
|
||||||
data = db_tools.get_contents_by_book(book)
|
data = db_tools.get_contents_by_book(book)
|
||||||
if data:
|
if data:
|
||||||
title = data['title']
|
title = data['title']
|
||||||
|
|||||||
@ -14,6 +14,7 @@ global_share_data_dir = f'{home_dir}/sharedata'
|
|||||||
log_count = defaultdict(int) # 记录日志的次数
|
log_count = defaultdict(int) # 记录日志的次数
|
||||||
last_log_time = defaultdict(float) # 记录上次写入的时间戳
|
last_log_time = defaultdict(float) # 记录上次写入的时间戳
|
||||||
|
|
||||||
|
log_dir = '../log'
|
||||||
class RateLimitFilter(logging.Filter):
|
class RateLimitFilter(logging.Filter):
|
||||||
"""
|
"""
|
||||||
频率限制过滤器:
|
频率限制过滤器:
|
||||||
@ -50,7 +51,9 @@ def setup_logging(log_filename=None):
|
|||||||
caller_frame = inspect.stack()[1]
|
caller_frame = inspect.stack()[1]
|
||||||
caller_filename = os.path.splitext(os.path.basename(caller_frame.filename))[0]
|
caller_filename = os.path.splitext(os.path.basename(caller_frame.filename))[0]
|
||||||
current_date = datetime.now().strftime('%Y%m%d')
|
current_date = datetime.now().strftime('%Y%m%d')
|
||||||
log_filename = f'../log/{caller_filename}_{current_date}.log'
|
os.makedirs(log_dir, exist_ok=True)
|
||||||
|
log_filename = f'{log_dir}/{caller_filename}_{current_date}.log'
|
||||||
|
#log_filename = f'../log/{caller_filename}_{current_date}.log'
|
||||||
|
|
||||||
max_log_size = 100 * 1024 * 1024 # 10 MB
|
max_log_size = 100 * 1024 * 1024 # 10 MB
|
||||||
max_log_files = 10 # 最多保留 10 个日志文件
|
max_log_files = 10 # 最多保留 10 个日志文件
|
||||||
|
|||||||
@ -10,6 +10,7 @@ home_dir = os.path.expanduser("~")
|
|||||||
global_host_data_dir = f'{home_dir}/hostdir/scripts_data'
|
global_host_data_dir = f'{home_dir}/hostdir/scripts_data'
|
||||||
global_share_data_dir = f'{home_dir}/sharedata'
|
global_share_data_dir = f'{home_dir}/sharedata'
|
||||||
|
|
||||||
|
log_dir = '../log'
|
||||||
|
|
||||||
# 统计日志频率
|
# 统计日志频率
|
||||||
log_count = defaultdict(int) # 记录日志的次数
|
log_count = defaultdict(int) # 记录日志的次数
|
||||||
@ -50,7 +51,9 @@ def setup_logging(log_filename=None):
|
|||||||
caller_frame = inspect.stack()[1]
|
caller_frame = inspect.stack()[1]
|
||||||
caller_filename = os.path.splitext(os.path.basename(caller_frame.filename))[0]
|
caller_filename = os.path.splitext(os.path.basename(caller_frame.filename))[0]
|
||||||
current_date = datetime.now().strftime('%Y%m%d')
|
current_date = datetime.now().strftime('%Y%m%d')
|
||||||
log_filename = f'../log/{caller_filename}_{current_date}.log'
|
os.makedirs(log_dir, exist_ok=True)
|
||||||
|
log_filename = f'{log_dir}/{caller_filename}_{current_date}.log'
|
||||||
|
#log_filename = f'../log/{caller_filename}_{current_date}.log'
|
||||||
|
|
||||||
max_log_size = 100 * 1024 * 1024 # 10 MB
|
max_log_size = 100 * 1024 * 1024 # 10 MB
|
||||||
max_log_files = 10 # 最多保留 10 个日志文件
|
max_log_files = 10 # 最多保留 10 个日志文件
|
||||||
|
|||||||
Reference in New Issue
Block a user