[log] Add debug logging to config/docker_helpers.go#2824
Conversation
Enhance docker_helpers.go with debug logging using the existing logDockerHelpers logger to improve troubleshooting of Docker operations: - runDockerInspect: log before executing the docker inspect command and after success with output length - checkPortMapping: log entry with containerID/port and result with mapped status - checkStdinInteractive: log result with containerID and interactive flag - checkLogDirMounted: log result with containerID, logDir, and mounted status These debug logs are controlled via DEBUG=config:docker_helpers and help diagnose Docker environment validation issues during gateway startup. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds targeted debug logging to Docker inspection helpers in internal/config/docker_helpers.go to make containerized environment validation easier to diagnose when DEBUG=config:docker_helpers is enabled.
Changes:
- Added entry/success logging to
runDockerInspect(including output length). - Added input/result logging to
checkPortMapping, plus result logging tocheckStdinInteractiveandcheckLogDirMounted.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| return "", err | ||
| } | ||
|
|
||
| logDockerHelpers.Printf("Running docker inspect: containerID=%s, format=%s", containerID, formatTemplate) |
There was a problem hiding this comment.
For log readability/parsing, consider quoting string fields that may contain spaces/special chars. In particular, formatTemplate is a Go template (contains braces/quotes) and containerID is an identifier; using %q for formatTemplate (and possibly for other string fields in these new logs) will make the output unambiguous and help avoid multi-field confusion if the template ever includes whitespace.
| logDockerHelpers.Printf("Running docker inspect: containerID=%s, format=%s", containerID, formatTemplate) | |
| logDockerHelpers.Printf("Running docker inspect: containerID=%q, format=%q", containerID, formatTemplate) |
|
|
||
| return strings.TrimSpace(string(output)), nil | ||
| result := strings.TrimSpace(string(output)) | ||
| logDockerHelpers.Printf("Docker inspect succeeded: output_len=%d", len(result)) |
There was a problem hiding this comment.
The output_len field is computed from the trimmed string (len(result)), which may not match the raw docker inspect output size and is counted in bytes (Go string length). Consider either logging len(output) (raw bytes) or renaming the field to something like trimmed_len/result_len to avoid misleading diagnostics.
| logDockerHelpers.Printf("Docker inspect succeeded: output_len=%d", len(result)) | |
| logDockerHelpers.Printf("Docker inspect succeeded: result_len=%d", len(result)) |
Enhances
internal/config/docker_helpers.gowith debug logging using the existinglogDockerHelperslogger ("config:docker_helpers").Changes
Six new
logDockerHelpers.Printf(...)calls added to Docker inspection functions that previously had no debug output:runDockerInspectcontainerID/format, success log withoutput_lencheckPortMappingcontainerID/port, result log withmappedstatuscheckStdinInteractivecontainerID/interactiveflagcheckLogDirMountedcontainerID/logDir/mountedflagThe
ExpandEnvArgsfunction already had logging; the other functions previously had none.Usage
Enable with:
Or together with other docker-related namespaces:
DEBUG=config:* ./awmg --config config.tomlChecklist
logDockerHelpers = logger.New("config:docker_helpers")declarationpkg:filenameconvention