Skip to content

[log] Add debug logging to core compilation and CLI files#3860

Merged
pelikhan merged 1 commit into
mainfrom
log-enhancement-session-3-67ad9991b99f61d7
Nov 13, 2025
Merged

[log] Add debug logging to core compilation and CLI files#3860
pelikhan merged 1 commit into
mainfrom
log-enhancement-session-3-67ad9991b99f61d7

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

Summary

Enhanced 5 core compilation and CLI files with comprehensive debug logging to improve troubleshooting and development workflow visibility. This is the third session of logging enhancements, focusing on the main compilation pipeline files.

Files Enhanced

  1. pkg/workflow/compiler_yaml.go (6 logging additions)

    • Main job steps generation with workflow context
    • Checkout step decisions
    • Runtime requirements detection
    • Engine installation steps tracking
    • Prompt generation and chunking
  2. pkg/workflow/expressions.go (5 logging additions)

    • Expression tokenization
    • Condition tree building logic
    • Boolean operator combination decisions
    • Reaction condition building
    • Primary expression parsing (with Enabled() check)
  3. pkg/workflow/safe_outputs.go (6 logging additions)

    • Safe output job building
    • Pre-steps tracking
    • Job condition and dependency decisions
    • Prompt section generation
    • Configuration generation
  4. pkg/workflow/mcp-config.go (4 logging additions)

    • MCP type detection (explicit vs inferred)
    • Type inference for http/stdio/container
    • Field extraction phases
    • Custom MCP config rendering
  5. pkg/cli/compile_command.go (5 logging additions)

    • Validation mode status
    • No-emit mode status
    • File compilation counts
    • Directory compilation tracking
    • Markdown file discovery

Quality Assurance

✅ All files already had logger declarations (no new loggers needed)
✅ Logger arguments have no side effects
✅ Uses log.Enabled() check for expensive debug info
✅ All logging follows project guidelines from AGENTS.md
✅ No test files modified
✅ Validated with make build (successful compilation)
✅ Tested with DEBUG=* ./gh-aw compile dev (logging works correctly)
✅ Cache updated with processed files

Debug Output Sample

cli:compile_command Starting workflow compilation: files=1, validate=false, watch=false, noEmit=false
cli:compile_command Using default workflow directory: .github/workflows
cli:compile_command Created compiler instance
cli:compile_command Validation enabled: false
cli:compile_command Compiling 1 specific workflow files
workflow:compiler_yaml Generating YAML for workflow: Dev
workflow:compiler_yaml Generating main job steps for workflow: Dev
workflow:compiler_yaml Checkout step needed: true
workflow:compiler_yaml Detected runtime requirements: 0 runtimes, 0 setup steps
workflow:compiler_yaml Adding 3 engine installation steps for copilot
workflow:safe_outputs Extracting safe-outputs configuration from frontmatter
workflow:safe_outputs Safe outputs enabled check: true
workflow:compiler_yaml Generating prompt for workflow: Dev (markdown size: 1103 bytes)
workflow:compiler_yaml Split prompt into 1 chunks
workflow:safe_outputs Generating safe outputs prompt section
workflow:mcp-config Rendering custom MCP config wrapper for tool: playwright

Impact

This PR enhances debugging capabilities for the core compilation pipeline, making it easier to:

  • Troubleshoot workflow compilation issues
  • Understand the compilation flow
  • Track decisions made during YAML generation
  • Debug expression parsing and safe outputs configuration
  • Monitor MCP server setup

Related Work

  • Session 1 (commit c7daf1d): Enhanced 5 engine and safe-outputs files
  • Session 2 (commit b4fac9a): Enhanced 5 workflow job building files
  • Session 3 (this PR): Enhanced 5 core compilation and CLI files

Total: 15 files enhanced across 3 sessions

🤖 Generated with Claude Code

AI generated by Go Logger Enhancement

Enhanced 5 core files with comprehensive debug logging to improve troubleshooting and development workflow visibility:

1. **pkg/workflow/compiler_yaml.go**:
   - Added logging to generateMainJobSteps with workflow name
   - Log checkout step decision
   - Log runtime requirements detection with counts
   - Log engine installation steps with engine ID
   - Log prompt generation with content size
   - Log prompt chunking with chunk count

2. **pkg/workflow/expressions.go**:
   - Added logging to tokenize with expression length
   - Log buildConditionTree with existing and draft conditions
   - Log condition combination logic (AND vs draft-only)
   - Log buildReactionCondition for multiple event types
   - Log parsePrimaryExpression with token details (using Enabled() check)

3. **pkg/workflow/safe_outputs.go**:
   - Added logging to buildSafeOutputJob with job name
   - Log pre-steps count
   - Log job condition decision (custom vs default)
   - Log job needs/dependencies
   - Log generateSafeOutputsPromptSection entry
   - Log generateSafeOutputsConfig entry

4. **pkg/workflow/mcp-config.go**:
   - Added logging to getMCPConfig for MCP type detection
   - Log inferred type for http/stdio/container
   - Log field extraction phase with MCP type
   - Log renderCustomMCPConfigWrapper with tool name

5. **pkg/cli/compile_command.go**:
   - Added logging for validation enabled/disabled status
   - Log no-emit mode status
   - Log file compilation count at start
   - Log compileAllWorkflowFiles directory entry
   - Log markdown file count found in directory

All logging follows project guidelines:
- Uses existing logger declarations (all files already had loggers)
- Logger arguments have no side effects
- Uses Enabled() check for potentially expensive debug info
- Focuses on function entry, control flow, and key decisions
- Messages are meaningful and helpful for debugging

Validated:
- All files compile successfully (make build)
- Debug logging works correctly (DEBUG=* ./gh-aw compile dev)
- Cache updated with processed files

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added automation enhancement New feature or request labels Nov 13, 2025
@pelikhan pelikhan merged commit 132f269 into main Nov 13, 2025
4 checks passed
@pelikhan pelikhan deleted the log-enhancement-session-3-67ad9991b99f61d7 branch November 13, 2025 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant