fix: move cargo-wdk output to stderr
Summary
- Configures
cargo-wdkto 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.rsto add.with_writer(std::io::stderr)to thetracing_subscriberconfiguration - This redirects all
info!,debug!,warn!, anderror!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 ascargo buildoutput - 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
Thanks for the PR @cnaples79. We will have a look at it in the next few days.
@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.