Skip to content

feat: add stack_name to Docker Compose SDK log messages#17

Merged
veerendra2 merged 1 commit intomainfrom
feat/add-stack-name-to-logs
Apr 13, 2026
Merged

feat: add stack_name to Docker Compose SDK log messages#17
veerendra2 merged 1 commit intomainfrom
feat/add-stack-name-to-logs

Conversation

@veerendra2
Copy link
Copy Markdown
Owner

@veerendra2 veerendra2 commented Apr 12, 2026

Summary

  • Add stack_name to warning logs emitted by the Docker Compose SDK (logrus → slog bridge) during LoadProject, making it easy to identify which stack has unset environment variables

Before

time=2026-04-12T18:20:48Z level=WARN source=/app/pkg/dockercompose/logger.go:62 msg="The \"WORDPRESS_DB_HOST\" variable is not set. Defaulting to a blank string."

After

time=2026-04-12T18:20:48Z level=WARN source=/app/pkg/dockercompose/logger.go:84 msg="The \"WORDPRESS_DB_HOST\" variable is not set. Defaulting to a blank string." stack_name=wordpress

Test plan

  • Deploy a stack with unset env variables and verify stack_name appears in the warning logs
  • Deploy a stack with all env variables set and verify no extra log noise

🤖 Generated with Claude Code

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown

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 stack_name context to Docker Compose SDK warning logs (logrus → slog bridge) during LoadProject so warnings about unset env vars can be attributed to a specific stack.

Changes:

  • Introduce a shared slogHook that stores the current stack name (RWMutex-protected) and attaches it to forwarded logrus messages.
  • Extend slogWriter to optionally include stack_name in Docker CLI stream logs via the same hook.
  • Set/clear the hook’s stack name for the duration of client.LoadProject() (derived from filepath.Base(WorkingDir)).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
pkg/dockercompose/logger.go Adds stack-name-aware state to the logrus→slog hook and uses it when emitting slog records.
pkg/dockercompose/compose.go Wires the hook into the client and sets stack_name around LoadProject; passes hook into slogWriter.

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

@veerendra2 veerendra2 added the build Builds dev docker image label Apr 12, 2026
@veerendra2 veerendra2 merged commit 46e9908 into main Apr 13, 2026
8 checks passed
@veerendra2 veerendra2 deleted the feat/add-stack-name-to-logs branch April 13, 2026 08:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build Builds dev docker image

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants