Skip to content

Commit 0a5055a

Browse files
Add dedicated debug loggers to 5 pkg files for improved traceability (#20984)
1 parent 8d431ff commit 0a5055a

5 files changed

Lines changed: 30 additions & 0 deletions

File tree

pkg/parser/tools_merger.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@ import (
66
"fmt"
77
"maps"
88
"strings"
9+
10+
"github.com/github/gh-aw/pkg/logger"
911
)
1012

13+
var toolsMergerLog = logger.New("parser:tools_merger")
14+
1115
// mergeToolsFromJSON merges multiple JSON tool objects from content
1216
func mergeToolsFromJSON(content string) (string, error) {
1317
log.Printf("Merging tools from JSON: content_size=%d bytes", len(content))
@@ -158,6 +162,7 @@ func MergeTools(base, additional map[string]any) (map[string]any, error) {
158162

159163
// mergeAllowedArrays merges two allowed arrays and removes duplicates
160164
func mergeAllowedArrays(existing, new any) []any {
165+
toolsMergerLog.Print("Merging allowed arrays")
161166
var result []any
162167
seen := make(map[string]bool)
163168

@@ -190,6 +195,7 @@ func mergeAllowedArrays(existing, new any) []any {
190195

191196
// mergeMCPTools merges two MCP tool configurations, detecting conflicts except for 'allowed' arrays
192197
func mergeMCPTools(existing, new map[string]any) (map[string]any, error) {
198+
toolsMergerLog.Printf("Merging MCP tool configs: existing_keys=%d, new_keys=%d", len(existing), len(new))
193199
result := make(map[string]any)
194200

195201
// Copy existing properties

pkg/workflow/compiler_string_api.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,17 @@ import (
66
"path/filepath"
77
"time"
88

9+
"github.com/github/gh-aw/pkg/logger"
910
"github.com/github/gh-aw/pkg/parser"
1011
"github.com/github/gh-aw/pkg/stringutil"
1112
)
1213

14+
var compilerStringAPILog = logger.New("workflow:compiler_string_api")
15+
1316
// CompileToYAML compiles workflow data and returns the YAML as a string
1417
// without writing to disk. This is useful for Wasm builds and programmatic usage.
1518
func (c *Compiler) CompileToYAML(workflowData *WorkflowData, markdownPath string) (string, error) {
19+
compilerStringAPILog.Printf("CompileToYAML: markdownPath=%s", markdownPath)
1620
c.markdownPath = markdownPath
1721
c.skipHeader = true
1822
// Clear contentOverride after compilation (set by ParseWorkflowString)
@@ -94,6 +98,8 @@ func (c *Compiler) ParseWorkflowString(content string, virtualPath string) (*Wor
9498
return nil, err
9599
}
96100

101+
compilerStringAPILog.Printf("ParseWorkflowString: frontmatter validated, frontmatter_fields=%d", len(frontmatterForValidation))
102+
97103
// Build parse result to reuse the rest of the orchestrator pipeline
98104
parseResult := &frontmatterParseResult{
99105
cleanPath: cleanPath,

pkg/workflow/mcp_renderer_builtin.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@ import (
55
"strings"
66

77
"github.com/github/gh-aw/pkg/constants"
8+
"github.com/github/gh-aw/pkg/logger"
89
)
910

11+
var mcpRendererBuiltinLog = logger.New("workflow:mcp_renderer_builtin")
12+
1013
// RenderPlaywrightMCP generates the Playwright MCP server configuration
1114
func (r *MCPConfigRendererUnified) RenderPlaywrightMCP(yaml *strings.Builder, playwrightTool any) {
1215
mcpRendererLog.Printf("Rendering Playwright MCP: format=%s, inline_args=%t", r.options.Format, r.options.InlineArgs)
@@ -27,6 +30,7 @@ func (r *MCPConfigRendererUnified) RenderPlaywrightMCP(yaml *strings.Builder, pl
2730
// Per MCP Gateway Specification v1.0.0 section 3.2.1, stdio-based MCP servers MUST be containerized.
2831
// Uses MCP Gateway spec format: container, entrypointArgs, mounts, and args fields.
2932
func (r *MCPConfigRendererUnified) renderPlaywrightTOML(yaml *strings.Builder, playwrightConfig *PlaywrightToolConfig) {
33+
mcpRendererBuiltinLog.Print("Rendering Playwright MCP in TOML format")
3034
customArgs := getPlaywrightCustomArgs(playwrightConfig)
3135

3236
// Use official Playwright MCP Docker image (no version tag - only one image)
@@ -82,6 +86,7 @@ func (r *MCPConfigRendererUnified) RenderSerenaMCP(yaml *strings.Builder, serena
8286
// - "docker" (default): Uses Docker container with stdio transport
8387
// - "local": Uses local uvx with HTTP transport
8488
func (r *MCPConfigRendererUnified) renderSerenaTOML(yaml *strings.Builder, serenaTool any) {
89+
mcpRendererBuiltinLog.Print("Rendering Serena MCP in TOML format")
8590
customArgs := getSerenaCustomArgs(serenaTool)
8691

8792
yaml.WriteString(" \n")
@@ -221,6 +226,7 @@ func (r *MCPConfigRendererUnified) RenderAgenticWorkflowsMCP(yaml *strings.Build
221226
// renderAgenticWorkflowsTOML generates Agentic Workflows MCP configuration in TOML format
222227
// Per MCP Gateway Specification v1.0.0 section 3.2.1, stdio-based MCP servers MUST be containerized.
223228
func (r *MCPConfigRendererUnified) renderAgenticWorkflowsTOML(yaml *strings.Builder) {
229+
mcpRendererBuiltinLog.Printf("Rendering Agentic Workflows MCP in TOML format: action_mode=%s", r.options.ActionMode)
224230
yaml.WriteString(" \n")
225231
yaml.WriteString(" [mcp_servers." + constants.AgenticWorkflowsMCPServerID.String() + "]\n")
226232

pkg/workflow/safe_outputs_call_workflow.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@ import (
44
"fmt"
55
"sort"
66

7+
"github.com/github/gh-aw/pkg/logger"
78
"github.com/github/gh-aw/pkg/stringutil"
89
)
910

11+
var safeOutputsCallWorkflowLog = logger.New("workflow:safe_outputs_call_workflow")
12+
1013
// ========================================
1114
// Safe Output Call Workflow Handling
1215
// ========================================
@@ -70,6 +73,8 @@ func populateCallWorkflowFiles(data *WorkflowData, markdownPath string) {
7073
// The agent calls this tool to select which worker to activate; the handler writes
7174
// call_workflow_name and call_workflow_payload outputs for the conditional `uses:` jobs.
7275
func generateCallWorkflowTool(workflowName string, workflowInputs map[string]any) map[string]any {
76+
safeOutputsCallWorkflowLog.Printf("Generating call-workflow tool: workflow=%s, inputs=%d", workflowName, len(workflowInputs))
77+
7378
// Normalize workflow name to use underscores for tool name
7479
toolName := stringutil.NormalizeSafeOutputIdentifier(workflowName)
7580

@@ -158,5 +163,6 @@ func generateCallWorkflowTool(workflowName string, workflowInputs map[string]any
158163
tool["inputSchema"].(map[string]any)["required"] = required
159164
}
160165

166+
safeOutputsCallWorkflowLog.Printf("Generated call-workflow tool: name=%s, properties=%d, required=%d", toolName, len(properties), len(required))
161167
return tool
162168
}

pkg/workflow/safe_outputs_dispatch.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@ import (
44
"fmt"
55
"sort"
66

7+
"github.com/github/gh-aw/pkg/logger"
78
"github.com/github/gh-aw/pkg/stringutil"
89
)
910

11+
var safeOutputsDispatchWorkflowLog = logger.New("workflow:safe_outputs_dispatch")
12+
1013
// ========================================
1114
// Safe Output Dispatch Workflow Handling
1215
// ========================================
@@ -68,6 +71,8 @@ func populateDispatchWorkflowFiles(data *WorkflowData, markdownPath string) {
6871
// The tool will be named after the workflow (normalized to underscores) and accept
6972
// the workflow's defined workflow_dispatch inputs as parameters.
7073
func generateDispatchWorkflowTool(workflowName string, workflowInputs map[string]any) map[string]any {
74+
safeOutputsDispatchWorkflowLog.Printf("Generating dispatch-workflow tool: workflow=%s, inputs=%d", workflowName, len(workflowInputs))
75+
7176
// Normalize workflow name to use underscores for tool name
7277
toolName := stringutil.NormalizeSafeOutputIdentifier(workflowName)
7378

@@ -160,5 +165,6 @@ func generateDispatchWorkflowTool(workflowName string, workflowInputs map[string
160165
tool["inputSchema"].(map[string]any)["required"] = required
161166
}
162167

168+
safeOutputsDispatchWorkflowLog.Printf("Generated dispatch-workflow tool: name=%s, properties=%d, required=%d", toolName, len(properties), len(required))
163169
return tool
164170
}

0 commit comments

Comments
 (0)