clear log
Browse files- owl/webapp_zh.py +21 -5
owl/webapp_zh.py
CHANGED
@@ -544,9 +544,25 @@ def create_ui():
|
|
544 |
"""获取最新日志并返回给前端显示"""
|
545 |
return get_latest_logs(100)
|
546 |
|
547 |
-
def
|
548 |
-
"""
|
549 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
550 |
|
551 |
# 创建一个实时日志更新函数
|
552 |
def process_with_live_logs(question, module_name):
|
@@ -958,7 +974,7 @@ def create_ui():
|
|
958 |
value=True,
|
959 |
interactive=True
|
960 |
)
|
961 |
-
clear_logs_button = gr.Button("
|
962 |
|
963 |
with gr.TabItem("环境变量管理", id="env-settings"):
|
964 |
gr.Markdown("""
|
@@ -1109,7 +1125,7 @@ def create_ui():
|
|
1109 |
)
|
1110 |
|
1111 |
clear_logs_button.click(
|
1112 |
-
fn=
|
1113 |
outputs=[log_display]
|
1114 |
)
|
1115 |
|
|
|
544 |
"""获取最新日志并返回给前端显示"""
|
545 |
return get_latest_logs(100)
|
546 |
|
547 |
+
def clear_log_file():
|
548 |
+
"""清空日志文件内容"""
|
549 |
+
try:
|
550 |
+
if LOG_FILE and os.path.exists(LOG_FILE):
|
551 |
+
# 清空日志文件内容而不是删除文件
|
552 |
+
open(LOG_FILE, 'w').close()
|
553 |
+
logging.info("日志文件已清空")
|
554 |
+
# 清空日志队列
|
555 |
+
while not LOG_QUEUE.empty():
|
556 |
+
try:
|
557 |
+
LOG_QUEUE.get_nowait()
|
558 |
+
except queue.Empty:
|
559 |
+
break
|
560 |
+
return "日志文件已清空"
|
561 |
+
else:
|
562 |
+
return "日志文件不存在或未设置"
|
563 |
+
except Exception as e:
|
564 |
+
logging.error(f"清空日志文件时出错: {str(e)}")
|
565 |
+
return f"清空日志文件时出错: {str(e)}"
|
566 |
|
567 |
# 创建一个实时日志更新函数
|
568 |
def process_with_live_logs(question, module_name):
|
|
|
974 |
value=True,
|
975 |
interactive=True
|
976 |
)
|
977 |
+
clear_logs_button = gr.Button("清空日志", variant="secondary")
|
978 |
|
979 |
with gr.TabItem("环境变量管理", id="env-settings"):
|
980 |
gr.Markdown("""
|
|
|
1125 |
)
|
1126 |
|
1127 |
clear_logs_button.click(
|
1128 |
+
fn=clear_log_file,
|
1129 |
outputs=[log_display]
|
1130 |
)
|
1131 |
|