Skip to content

wslc: add --details to container logs for docker parity - #41467

Open
ggarzia-MSFT wants to merge 5 commits into
masterfrom
user/ggarzia/wslc-logs-details
Open

wslc: add --details to container logs for docker parity#41467
ggarzia-MSFT wants to merge 5 commits into
masterfrom
user/ggarzia/wslc-logs-details

Conversation

@ggarzia-MSFT

@ggarzia-MSFT ggarzia-MSFT commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Summary of the Pull Request

Adds the --details option to wslc container logs (and its wslc logs alias) for docker CLI parity.

docker logs --details asks the daemon to include the extra attributes that were supplied to the container's logging driver alongside each log line. wslc logs had no equivalent, so those attributes were unreachable from the CLI.

The flag is plumbed straight through to the Docker GET /containers/{id}/logs endpoint as the details query parameter, alongside the existing follow/timestamps/tail parameters.

PR Checklist

  • Closes: Link to issue #xxx
  • Communication: I've discussed this with core contributors already. If work hasn't been agreed, this work might be rejected
  • Tests: Added/updated if needed and all pass
  • Localization: All end user facing strings can be localized
  • Dev docs: Added/updated if needed
  • Documentation updated: If checked, please file a pull request on our docs repo and link it here: #xxx

Detailed Description of the Pull Request / Additional comments

Docker parity

docker/cli cli/command/container/logs.go declares the option as:

flags.BoolVar(&opts.details, "details", false, "Show extra details provided to logs")

Note BoolVar, not BoolVarP — docker deliberately gives --details no short alias. This change matches that: ArgType::Details is registered with NO_ALIAS, so container logs -d is not accepted.

Query parameter encoding

The flag needs no client-side interpretation; it is handed to DockerHTTPClient::URL::SetParameter as a bool, exactly like the neighbouring follow, stdout, stderr and timestamps parameters, so the request carries details=true or details=false.

That differs textually from docker's own client, which omits the parameter when false and sets it to 1 when true (moby/moby client/container_logs.go):

if options.Details {
    query.Set("details", "1")
}

Both encodings are equivalent at the daemon, which parses the parameter with httputils.BoolValue (moby/moby daemon/server/httputils/form.go):

func BoolValue(r *http.Request, k string) bool {
    switch strings.ToLower(strings.TrimSpace(r.FormValue(k))) {
    case "", "0", "no", "false", "none":
        return false
    default:
        return true
    }
}

"true" falls into the default branch and enables details; "false" is in the false list and is indistinguishable from omitting the parameter. Keeping the bool overload therefore preserves observable behaviour while staying consistent with how every other boolean parameter in DockerHTTPClient.cpp is serialized.

Validation Steps Performed

Parser coverage (CommandLineTestCases.h) — 6 new cases:

  • container logs --details cont1 and the root logs --details cont1 alias
  • --details=true / --details=false explicit forms
  • --details=invalid rejected
  • --details combined with --timestamps and --tail

Unit tests (WSLCCLICommandUnitTests.cpp):

  • The pre-existing AllCommands_NoAmbiguousArgumentNamesOrAliases tree walk continues to pass, confirming the new argument introduces no name or alias collisions anywhere in the command tree.

End-to-end tests (WSLCE2EContainerLogsTests.cpp):

  • WSLCE2E_Container_Logs_Details — runs a container emitting two lines, then verifies that logs --details exits 0 and that its output differs from a plain logs. The daemon serializes the log driver attributes followed by a separator space, and emits that separator unconditionally, so a container with no configured attributes still gains exactly one leading space per line (" detail1\n detail2\n" versus "detail1\ndetail2\n"). That difference is the observable proof the flag reached the daemon. The test also checks that --details --tail 1 still tails correctly.
  • WSLCE2E_Container_Logs_Details_ListedInHelp — the flag and its description appear in container logs --help.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings August 28, 2026 00:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds Docker CLI parity for wslc container logs/wslc logs by introducing a --details flag, plumbing it through the CLI/task/service layers into the Docker Engine GET /containers/{id}/logs request, and validating behavior via parser, unit, and E2E tests.

Changes:

  • Introduce a new ArgType::Details flag (no short alias) for container logs and ensure help text is localized.
  • Thread the details option through ContainerTasksContainerService → container COM flags → Docker HTTP query parameter.
  • Add parser test cases, a CLI command unit test, and E2E coverage (including “no short alias” enforcement and help output).

Reviewed changes

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

Show a summary per file
File Description
test/windows/wslc/WSLCCLICommandUnitTests.cpp Adds a unit test asserting --details exists and has no short alias.
test/windows/wslc/e2e/WSLCE2EContainerLogsTests.cpp Adds E2E coverage for --details, -d rejection, and help output.
test/windows/wslc/CommandLineTestCases.h Extends command-line parsing coverage for --details and invalid values/alias behavior.
src/windows/wslcsession/DockerHTTPClient.cpp Adds details query parameter on container logs requests when the new flag is set.
src/windows/wslc/tasks/ContainerTasks.cpp Parses --details and forwards it into the logs service call.
src/windows/wslc/services/ContainerService.h Extends ContainerService::Logs API to include a details boolean.
src/windows/wslc/services/ContainerService.cpp Converts the details boolean into WSLCLogsFlagsDetails.
src/windows/wslc/commands/ContainerLogsCommand.cpp Registers the --details argument for the logs command.
src/windows/wslc/arguments/ArgumentDefinitions.h Defines the Details argument (NO_ALIAS) and binds its localized description.
src/windows/service/inc/WSLCShared.idl Adds WSLCLogsFlagsDetails and updates valid-flag mask.
localization/strings/en-US/Resources.resw Adds localized help text for the new --details flag.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 28, 2026 21:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

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

Comment thread src/windows/wslcsession/DockerHTTPClient.cpp
Comment thread test/windows/wslc/e2e/WSLCE2EContainerLogsTests.cpp
@ggarzia-MSFT
ggarzia-MSFT marked this pull request as ready for review September 1, 2026 17:01
@ggarzia-MSFT
ggarzia-MSFT requested review from a team as code owners September 1, 2026 17:01
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings September 1, 2026 18:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Suppressed comments (2)

Previously missed (2) — in code that hasn't changed since the last review.

test/windows/wslc/e2e/WSLCE2EContainerLogsTests.cpp:79

  • This test currently asserts an exact stdout string for --details (including the exact prefix formatting). That makes the E2E test brittle against Docker engine/log formatting changes that still preserve the semantic requirement (details output differs from plain output). Consider verifying exit code + presence of expected log lines, and keep the key invariant (plain != details) without pinning the full formatting.
        auto details = RunWslc(std::format(L"container logs --details {}", WslcContainerName));
        details.Verify({.Stdout = L" detail1\n detail2\n", .Stderr = L"", .ExitCode = 0});
        VERIFY_ARE_NOT_EQUAL(plain.Stdout.value(), details.Stdout.value());

        // --details composes with the other log options.

test/windows/wslc/e2e/WSLCE2EContainerLogsTests.cpp:88

  • The help test hard-codes the English description text. Since help output is localized and the string already has a Localization::WSLCCLI_DetailsArgDescription() resource, using the localization accessor will keep the test stable if the wording changes.
        auto result = RunWslc(L"container logs --help");
        result.Verify({.Stderr = L"", .ExitCode = 0});
        VERIFY_IS_TRUE(result.StdoutContainsSubstring(L"--details"));
        VERIFY_IS_TRUE(result.StdoutContainsSubstring(L"Show extra details provided to logs"));
    }

Comment on lines +293 to +298
COMMAND_LINE_TEST_CASE(L"container logs --details cont1", L"logs", true)
COMMAND_LINE_TEST_CASE(L"logs --details cont1", L"logs", true)
COMMAND_LINE_TEST_CASE(L"container logs --details=true cont1", L"logs", true)
COMMAND_LINE_TEST_CASE(L"container logs --details=false cont1", L"logs", true)
COMMAND_LINE_TEST_CASE(L"container logs --details=invalid cont1", L"logs", false)
COMMAND_LINE_TEST_CASE(L"container logs --details --timestamps --tail 5 cont1", L"logs", true)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

But what if another option adds a d alias... this seems like improper negative testing.

ggarzia-MSFT and others added 2 commits September 1, 2026 13:14
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
<value>Run container in detached mode</value>
</data>
<data name="WSLCCLI_DetailsArgDescription" xml:space="preserve">
<value>Show extra details provided to logs</value>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
<value>Show extra details provided to logs</value>
<value>Show extra details for logs</value>

"provided to" sounds awkward.

Copilot AI review requested due to automatic review settings September 2, 2026 01:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The --details option is plumbed consistently across layers, the flags validation is updated correctly, and targeted tests were added/updated to cover parsing and end-to-end behavior.

Review details
  • Files reviewed: 11/11 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

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.

3 participants