From 1d114f034bf8783ae52f048e5ee5c1053d711a22 Mon Sep 17 00:00:00 2001 From: Wang Qi Date: Thu, 7 May 2026 15:03:08 +0800 Subject: [PATCH] Allow more task logs for #14617 (#14624) ### What problem does this PR solve? Allow more task logs for #14617 ### Type of change - [x] Refactoring --- api/db/services/task_service.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/api/db/services/task_service.py b/api/db/services/task_service.py index cb9967f08a..640c8fbd25 100644 --- a/api/db/services/task_service.py +++ b/api/db/services/task_service.py @@ -37,6 +37,7 @@ from rag.nlp import search CANVAS_DEBUG_DOC_ID = "dataflow_x" GRAPH_RAPTOR_FAKE_DOC_ID = "graph_raptor_x" +TASK_MAX_LOG_LENGTH = int(os.environ.get("TASK_MAX_LOG_LENGTH", 3000)) # TEXT MAX is 64 KiB bytes! def trim_header_by_lines(text: str, max_length) -> str: # Trim header text to maximum length while preserving line breaks @@ -320,7 +321,7 @@ class TaskService(CommonService): if os.environ.get("MACOS"): if info["progress_msg"]: - progress_msg = trim_header_by_lines(task.progress_msg + "\n" + info["progress_msg"], 3000) + progress_msg = trim_header_by_lines(task.progress_msg + "\n" + info["progress_msg"], TASK_MAX_LOG_LENGTH) cls.model.update(progress_msg=progress_msg).where(cls.model.id == id).execute() if "progress" in info: prog = info["progress"] @@ -332,7 +333,7 @@ class TaskService(CommonService): else: with DB.lock("update_progress", -1): if info["progress_msg"]: - progress_msg = trim_header_by_lines(task.progress_msg + "\n" + info["progress_msg"], 3000) + progress_msg = trim_header_by_lines(task.progress_msg + "\n" + info["progress_msg"], TASK_MAX_LOG_LENGTH) cls.model.update(progress_msg=progress_msg).where(cls.model.id == id).execute() if "progress" in info: prog = info["progress"]