From 4af166ea48f7b746c9eb6783ac398ade3cfdeea1 Mon Sep 17 00:00:00 2001 From: "tao.chen" <93983997+taochen-ct@users.noreply.github.com> Date: Tue, 14 Jul 2026 10:51:03 +0800 Subject: [PATCH] =?UTF-8?q?tools:=20spark=5Fsubmit=20=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E6=8B=BC=E8=A3=85=E5=91=BD=E4=BB=A4=E5=88=B0=20per-tool=20log?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 之前 d.Logger.Debug("spark_submit.built", "argv", cmd) 在 spark-submit 执行前 log 一次, 但 LOG_LEVEL=info 默认看不到, 拼装结果只活在 运行时 stack. 现在把 binary + argv 合并进 callLog.WithResult 写入 per-tool 文件 (data/logs/tools/_spark_submit_.log), 每次 执行都在 tail -f 的现场能 grep 出来. tail -f data/logs/tools/*.log | grep -A1 '"argv"' -> 看每次实际传给 spark-submit 的 argv, 含 script_path 在最后 保留 Debug 调用: verbose 模式下用 base.Logger 直接看到完整 argv 跟 cluster_id, 不依赖 file tail. 两份记录 (Debug + WithResult) 字段一致, 都是 binary + argv, 排查 spark-submit 行为时可以交叉对照. 测试: - 已有 TestSparkSubmit_StructuredCommand 跑通, argv 字段被 JSON marshal 进 resultRaw, 不需要新增测试 - go test ./... 全绿 Co-Authored-By: Claude --- internal/mcp/tools/spark_submit.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/internal/mcp/tools/spark_submit.go b/internal/mcp/tools/spark_submit.go index c9e6489..4be2493 100644 --- a/internal/mcp/tools/spark_submit.go +++ b/internal/mcp/tools/spark_submit.go @@ -176,6 +176,8 @@ func (d *Deps) SparkSubmitHandler(ctx context.Context, req mcp.CallToolRequest) // Even on error, result carries ExitCode/Stderr for the LLM. if result != nil { callLog.WithResult(map[string]any{ + "binary": binary, + "argv": cmd, "app_id": result.AppID, "exit_code": result.ExitCode, "duration_ms": result.DurationMS, @@ -193,6 +195,8 @@ func (d *Deps) SparkSubmitHandler(ctx context.Context, req mcp.CallToolRequest) } callLog.WithResult(map[string]any{ + "binary": binary, + "argv": cmd, "app_id": result.AppID, "exit_code": result.ExitCode, "duration_ms": result.DurationMS,