Skip to content

[log] Add debug logging to container detection#488

Merged
lpcox merged 1 commit into
mainfrom
add-logging-tty-container-d359fd8c4e1cda3f
Feb 1, 2026
Merged

[log] Add debug logging to container detection#488
lpcox merged 1 commit into
mainfrom
add-logging-tty-container-d359fd8c4e1cda3f

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

Summary

Adds comprehensive debug logging to internal/tty/container.go to improve troubleshooting and development visibility when detecting container environments.

Changes

Enhanced the IsRunningInContainer() function with 6 meaningful debug log statements:

  1. Function entry - Logs when container detection starts
  2. Docker detection - Logs when /.dockerenv file is found
  3. cgroup detection - Logs when /proc/1/cgroup contains container indicators
  4. Error handling - Logs when /proc/1/cgroup read fails
  5. Environment variable detection - Logs when RUNNING_IN_CONTAINER=true
  6. Negative case - Logs when not running in a container

Logging Details

  • Logger namespace: tty:container (follows pkg:filename convention)
  • Import added: github.com/githubnext/gh-aw-mcpg/internal/logger
  • No side effects: All log arguments are simple variables or strings
  • Control flow coverage: Logs all detection paths including error cases

Testing

The changes follow the project's logging guidelines from AGENTS.md:

  • ✅ Logger naming convention followed (tty:container)
  • ✅ No side effects in logger arguments
  • ✅ Meaningful messages for debugging
  • ✅ Function entry logged
  • ✅ Control flow decisions logged
  • ✅ Error cases logged

Debug Output

When running with DEBUG=tty:* ./awmg, you'll see:

tty:container Detecting container environment
tty:container Container detected: /.dockerenv file exists

Or in non-container environments:

tty:container Detecting container environment
tty:container Failed to read /proc/1/cgroup: open /proc/1/cgroup: permission denied
tty:container Not running in container

This provides valuable insight into how the container detection logic executes in different environments.

AI generated by Go Logger Enhancement

@github-actions
Copy link
Copy Markdown
Contributor Author

Smoke Test Results

Last 2 Merged PRs:

Test Results:
✅ GitHub MCP
✅ Serena MCP
✅ Playwright
✅ File Writing
✅ Bash Tool

Overall: PASS

cc: @github-actions

AI generated by Smoke Copilot

@github-actions
Copy link
Copy Markdown
Contributor Author

Smoke Test Results - Copilot Engine

PRs Tested: #502 (fixed agent prompt), #500 (changed debug env var)

✅ GitHub MCP
✅ Serena MCP
✅ Playwright
✅ File Writing
✅ Bash Tool

Overall Status: PASS

cc @github-actions[bot]

AI generated by Smoke Copilot

@github-actions
Copy link
Copy Markdown
Contributor Author

github-actions Bot commented Feb 1, 2026

Smoke Test: Copilot - ✅ PASS

PRs Reviewed:

Test Results:
✅ GitHub MCP
✅ Serena MCP
✅ Playwright
✅ File Writing
✅ Bash Tool

Run: https://github.com/githubnext/gh-aw-mcpg/actions/runs/21553349035

AI generated by Smoke Copilot

@lpcox lpcox marked this pull request as ready for review February 1, 2026 18:00
@lpcox lpcox merged commit d53f3ff into main Feb 1, 2026
@lpcox lpcox deleted the add-logging-tty-container-d359fd8c4e1cda3f branch February 1, 2026 18:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants