diff --git a/pkg/cli/mcp_registry_list.go b/pkg/cli/mcp_registry_list.go index cc34becc73..ff3167ebf5 100644 --- a/pkg/cli/mcp_registry_list.go +++ b/pkg/cli/mcp_registry_list.go @@ -5,10 +5,14 @@ import ( "os" "github.com/github/gh-aw/pkg/console" + "github.com/github/gh-aw/pkg/logger" ) +var mcpRegistryListLog = logger.New("cli:mcp_registry_list") + // listAvailableServers shows a list of available MCP servers from the registry func listAvailableServers(registryURL string, verbose bool) error { + mcpRegistryListLog.Printf("Listing available MCP servers: registry_url=%s", registryURL) // Create registry client registryClient := NewMCPRegistryClient(registryURL) @@ -19,9 +23,12 @@ func listAvailableServers(registryURL string, verbose bool) error { servers, err := registryClient.SearchServers("") if err != nil { + mcpRegistryListLog.Printf("Failed to fetch MCP servers: %v", err) return fmt.Errorf("failed to fetch MCP servers: %w", err) } + mcpRegistryListLog.Printf("Retrieved %d servers from registry", len(servers)) + if verbose { fmt.Fprintln(os.Stderr, console.FormatVerboseMessage(fmt.Sprintf("Retrieved %d servers from registry", len(servers)))) if len(servers) > 0 { diff --git a/pkg/cli/run_workflow_tracking.go b/pkg/cli/run_workflow_tracking.go index 75347002e8..dbb5d6f66a 100644 --- a/pkg/cli/run_workflow_tracking.go +++ b/pkg/cli/run_workflow_tracking.go @@ -8,9 +8,12 @@ import ( "time" "github.com/github/gh-aw/pkg/console" + "github.com/github/gh-aw/pkg/logger" "github.com/github/gh-aw/pkg/workflow" ) +var runWorkflowTrackingLog = logger.New("cli:run_workflow_tracking") + // WorkflowRunInfo contains information about a workflow run type WorkflowRunInfo struct { URL string @@ -23,6 +26,7 @@ type WorkflowRunInfo struct { // getLatestWorkflowRunWithRetry gets information about the most recent run of the specified workflow // with retry logic to handle timing issues when a workflow has just been triggered func getLatestWorkflowRunWithRetry(lockFileName string, repo string, verbose bool) (*WorkflowRunInfo, error) { + runWorkflowTrackingLog.Printf("Getting latest workflow run: workflow=%s, repo=%s, max_retries=6", lockFileName, repo) const maxRetries = 6 const initialDelay = 2 * time.Second const maxDelay = 10 * time.Second @@ -36,6 +40,7 @@ func getLatestWorkflowRunWithRetry(lockFileName string, repo string, verbose boo // Capture the current time before we start polling // This helps us identify runs that were created after the workflow was triggered startTime := time.Now().UTC() + runWorkflowTrackingLog.Printf("Start time for polling: %s", startTime.Format(time.RFC3339)) // Create spinner outside the loop so we can update it var spinner *console.SpinnerWrapper @@ -81,6 +86,7 @@ func getLatestWorkflowRunWithRetry(lockFileName string, repo string, verbose boo output, err := cmd.Output() if err != nil { lastErr = fmt.Errorf("failed to get workflow runs: %w", err) + runWorkflowTrackingLog.Printf("Attempt %d/%d failed to get runs: %v", attempt+1, maxRetries, err) if verbose { fmt.Fprintln(os.Stderr, console.FormatErrorMessage(fmt.Sprintf("Attempt %d/%d failed: %v", attempt+1, maxRetries, err))) } @@ -89,6 +95,7 @@ func getLatestWorkflowRunWithRetry(lockFileName string, repo string, verbose boo if len(output) == 0 || string(output) == "[]" { lastErr = fmt.Errorf("no runs found for workflow") + runWorkflowTrackingLog.Printf("Attempt %d/%d: no runs found, output empty or []", attempt+1, maxRetries) console.LogVerbose(verbose, fmt.Sprintf("Attempt %d/%d: no runs found yet", attempt+1, maxRetries)) continue } @@ -139,6 +146,7 @@ func getLatestWorkflowRunWithRetry(lockFileName string, repo string, verbose boo // If we found a run and it was created after we started (within 30 seconds tolerance), // it's likely the run we just triggered if !createdAt.IsZero() && createdAt.After(startTime.Add(-30*time.Second)) { + runWorkflowTrackingLog.Printf("Found matching run: id=%d, created_at=%s, within_tolerance=true", run.DatabaseID, createdAt.Format(time.RFC3339)) console.LogVerbose(verbose, fmt.Sprintf("Found recent run (ID: %d) created at %v (started polling at %v)", run.DatabaseID, createdAt.Format(time.RFC3339), startTime.Format(time.RFC3339))) if spinner != nil { diff --git a/pkg/cli/validation_output.go b/pkg/cli/validation_output.go index bc87dd261b..f27ad3663b 100644 --- a/pkg/cli/validation_output.go +++ b/pkg/cli/validation_output.go @@ -5,8 +5,11 @@ import ( "os" "github.com/github/gh-aw/pkg/console" + "github.com/github/gh-aw/pkg/logger" ) +var validationOutputLog = logger.New("cli:validation_output") + // FormatValidationError formats validation errors for console output // Preserves structured error content while applying console styling // @@ -24,6 +27,7 @@ func FormatValidationError(err error) string { } errMsg := err.Error() + validationOutputLog.Printf("Formatting validation error: %s", errMsg) // Apply console formatting to the entire error message // This preserves structured multi-line errors while adding visual styling