windows-drivers-rs icon indicating copy to clipboard operation
windows-drivers-rs copied to clipboard

fix: move cargo-wdk output to stderr

Open cnaples79 opened this issue 3 months ago • 2 comments

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

cnaples79 avatar Oct 07 '25 21:10 cnaples79

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

gurry avatar Oct 08 '25 09:10 gurry

@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.

gurry avatar Oct 09 '25 01:10 gurry