Skip to content

Conversation

@cnaples79
Copy link

Summary

  • Configures cargo-wdk to write its output to stderr instead of stdout
  • Aligns with standard build tool conventions (cargo, rustc, gcc)

Rationale

As noted in #526, build tools like cargo build, rustc, and gcc emit their human-readable output to stderr, leaving stdout available for machine-readable output (e.g., cargo build --message-format=json). This PR brings cargo-wdk in line with this convention.

Changes

  • Modified crates/cargo-wdk/src/trace.rs to add .with_writer(std::io::stderr) to the tracing_subscriber configuration
  • This redirects all info!, debug!, warn!, and error! macro output to stderr

Benefits

  • Consistency: Matches the behavior of other Rust build tools
  • No output splitting: When redirecting streams (e.g., cargo wdk build > output.log), all build output now goes to the same stream as cargo build output
  • Future-proof: Leaves stdout available for potential machine-readable output formats

Testing

The change uses the standard tracing_subscriber::fmt::SubscriberBuilder::with_writer API, which is well-documented and widely used. CI will verify the build passes on supported platforms.

Fixes #526

Configure tracing_subscriber to write to stderr instead of stdout,
aligning with standard build tool conventions (cargo, rustc, gcc).

This change:
- Ensures cargo-wdk output appears on stderr like cargo build
- Prevents output splitting when redirecting stdout/stderr to files
- Leaves stdout available for potential machine-readable output
- Maintains consistency with other Rust build tooling

Fixes microsoft#526
@gurry
Copy link
Contributor

gurry commented Oct 8, 2025

Thanks for the PR @cnaples79. We will have a look at it in the next few days.

@gurry gurry requested a review from a team October 8, 2025 09:56
@gurry
Copy link
Contributor

gurry commented Oct 9, 2025

@cnaples79 The checks didn't pass bercause many of cargo-wdk's tests are failing after the change. That is because these tests try to verify what's emitted on stdout. They need to be changed to check stderr now.

Another change you may have to make is around the output of the Windows tools that cargo-wdk invokes e.g. stampinf, signtool etc. These tools emit to stdout instead of stderr. We will need to redirect them to stderr as well.

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.

Move cargo-wdk output to stderr

2 participants