dbrgn / tracing-test

Access and evaluate tracing logs in async and sync tests.
Apache License 2.0
62 stars 27 forks source link

Removing the print!? #38

Open urkle opened 6 months ago

urkle commented 6 months ago

https://github.com/dbrgn/tracing-test/blob/9b8aa601f00fd60c1eaf0a1642713e983282ab6a/tracing-test/src/subscriber.rs#L36-L37

Is this print really needed? for this crate to work? Can't we have thus suppressed?

dbrgn commented 6 months ago

The print is needed if you want the log output to show up in the terminal for failed tests.

Why would you want it suppressed?

urkle commented 6 months ago

Because it makes my test output very noisy for when tests pass since it'll display for ALL tests not just tests that are checking log output.

Couldn't we modify the logs_contain or logs_assert methods to spit out data for failed tests only? (would you be open to a PR for this?)

dbrgn commented 6 months ago

What test runner are you using, cargo test? That should usually capture all test output, and only show it for failing tests.

urkle commented 6 months ago

It is cargo test, but run via RustRover (Jetbrains IDE) which turns on output all the time so it can capture things :)

I'll recheck things tomorrow when I work on that project that would be using this.

dbrgn commented 6 months ago

We could add a Cargo build flag to suppress log output. I don't want to remove the print in the crate's default behavior though, it is very useful to debug failed tests.

dbrgn commented 4 months ago

@urkle is this still an issue for you? If yes, a PR with a cargo feature no-log-printing would be welcome.