Skip to content

[log] Add debug logging to dockerutil/env.go#1522

Merged
lpcox merged 1 commit intomainfrom
log/dockerutil-env-logging-c977e9e735ed07a2
Mar 3, 2026
Merged

[log] Add debug logging to dockerutil/env.go#1522
lpcox merged 1 commit intomainfrom
log/dockerutil-env-logging-c977e9e735ed07a2

Conversation

@github-actions
Copy link
Contributor

Changes

Adds a debug logger to internal/dockerutil/env.go to trace Docker -e flag environment variable expansion.

What was added

  • Logger declaration: var logDockerutil = logger.New("dockerutil:env") following the project's pkg:filename naming convention
  • 4 debug logging calls in ExpandEnvArgs:
    1. Function entry log with input arg count
    2. Per-env-var log when a variable is successfully found and expanded
    3. Per-env-var log when a referenced variable is not found in the process environment (key debugging signal)
    4. Completion log with output arg count

Why this is useful

ExpandEnvArgs is called when building Docker command arguments, converting passthrough -e VAR_NAME flags to -e VAR_NAME=value. Without logging, there's no visibility into:

  • Which env vars are being passed through to Docker containers
  • Which env vars are missing from the gateway process environment (a common misconfiguration)
  • Whether the expansion produced the expected number of args

The "not found" log is especially valuable - it highlights env vars that are referenced in config but not set in the environment, which is a common source of unexpected Docker container behavior.

Debug usage

# Enable dockerutil debug logging
DEBUG=dockerutil:* ./awmg --config config.toml

# Example output
[dockerutil:env] Expanding env args: input_count=8
[dockerutil:env] Expanding env var: name=GITHUB_PERSONAL_ACCESS_TOKEN
[dockerutil:env] Env var not found in process environment: name=MISSING_VAR
[dockerutil:env] Env args expansion complete: output_count=9

Quality checklist

  • Exactly 1 file modified
  • No test files modified
  • Logger declaration added following pkg:filename convention (dockerutil:env)
  • Logger arguments don't compute anything or cause side effects (only passes existing variable names/counts)
  • Logging messages are meaningful and helpful
  • No duplicate logging with existing logs
  • Import statements properly formatted with stdlib imports before external imports

Generated by Go Logger Enhancement

Add logger to internal/dockerutil/env.go to trace Docker -e flag
environment variable expansion. Logs:
- Function entry with arg count
- Each env var expansion (found vs not found in process environment)
- Completion with output count

This helps debug issues where Docker container environment variables
are unexpectedly missing or not being passed through correctly.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions bot added automation enhancement New feature or request labels Feb 28, 2026
@lpcox lpcox marked this pull request as ready for review March 3, 2026 09:19
Copilot AI review requested due to automatic review settings March 3, 2026 09:19
@lpcox lpcox merged commit 8d1a49e into main Mar 3, 2026
2 checks passed
@lpcox lpcox deleted the log/dockerutil-env-logging-c977e9e735ed07a2 branch March 3, 2026 09:19
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds debug-level tracing to internal/dockerutil/env.go so it’s easier to understand how Docker -e VAR_NAME arguments are expanded (or not) based on the gateway process environment.

Changes:

  • Introduces a dockerutil:env namespaced logger for this file.
  • Adds debug logs at function entry/exit and when env vars are expanded or missing.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

2 participants