Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

distinguish stdout and stderr in up logs #10070

Merged
merged 1 commit into from Dec 13, 2022
Merged

Conversation

ndeloof
Copy link
Contributor

@ndeloof ndeloof commented Dec 13, 2022

What I did
As we attach to containers to collect log, distinguish Stdout and Stderr, and print logs on os.Stdout/Stderr accordingly

Related issue
#fixes #8098

(not mandatory) A picture of a cute animal, if possible in relation to what you did
image

@codecov
Copy link

codecov bot commented Dec 13, 2022

Codecov Report

Base: 75.74% // Head: 77.02% // Increases project coverage by +1.27% 🎉

Coverage data is based on head (a0eccef) compared to base (3ee2ab8).
Patch has no changes to coverable lines.

Additional details and impacted files
@@            Coverage Diff             @@
##               v2   #10070      +/-   ##
==========================================
+ Coverage   75.74%   77.02%   +1.27%     
==========================================
  Files           2        2              
  Lines         235      235              
==========================================
+ Hits          178      181       +3     
+ Misses         50       48       -2     
+ Partials        7        6       -1     
Impacted Files Coverage Δ
pkg/e2e/framework.go 75.22% <0.00%> (+1.37%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@ndeloof ndeloof force-pushed the stdout_stderr branch 3 times, most recently from afb91f8 to 285b0ec Compare December 13, 2022 09:38
@ndeloof ndeloof requested review from glours, milas and ulyssessouza and removed request for glours and milas December 13, 2022 10:13
pkg/api/api.go Outdated
ContainerEventLog = iota
// ContainerEventErr is a ContainerEvent of type log on stderr. Line is set
ContainerEventErr = iota
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
ContainerEventErr = iota
ContainerEventErr

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
@ndeloof ndeloof merged commit 0368f19 into docker:v2 Dec 13, 2022
Copy link
Contributor

@glours glours left a comment

Choose a reason for hiding this comment

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

Arff I'm too late, wondering if removing the service name in the log won't break potential user tests? 😬

@@ -116,7 +115,7 @@ func (s *composeService) logContainers(ctx context.Context, consumer api.LogCons

name := getContainerNameWithoutProject(c)
w := utils.GetWriter(func(line string) {
consumer.Log(name, service, line)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we really want to remove the reference to the service name in the logs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's actually unused (this is legacy from early ECS-CLI-plugin 😅

@ndeloof ndeloof deleted the stdout_stderr branch December 13, 2022 13:50
@felixoi
Copy link

felixoi commented Dec 22, 2022

Does this really fix the issue? I'm using standalone version 2.14.2 and Ansible shows me that the logs of my docker-compose up -d borgmatic-mailcow end up in stderr:

        "stderr": "Container mailcowdockerized-borgmatic-mailcow-1  Running",
        "stderr_lines": [
            "Container mailcowdockerized-borgmatic-mailcow-1  Running"
        ],
        "stdout": "",
        "stdout_lines": []

EDIT: Oh this was about the logs of the attached container. I may be wrong here with the compose output itself.

@ndeloof
Copy link
Contributor Author

ndeloof commented Dec 22, 2022

@felixoi this is compose status message you see here.
this issue is about separation for stdout and stderr in container's log

@felixoi
Copy link

felixoi commented Dec 22, 2022

@ndeloof Yeah, saw this too late. Do you know if there is an existing issue for status messages, or is this wanted behaviour?

@milas
Copy link
Member

milas commented Jan 3, 2023

That's intended behavior -- since there are only two streams (stdout/stderr), the CLI writes its own output to stderr; this ensures you can capture container output (from stdout) without having Compose output mixed in

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Separate STDERR and STDOUT in docker compose output
5 participants