tracing-test icon indicating copy to clipboard operation
tracing-test copied to clipboard

Removing the print!?

Open urkle opened this issue 1 year ago • 6 comments

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?

urkle avatar Mar 17 '24 23:03 urkle

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?

dbrgn avatar Mar 18 '24 08:03 dbrgn

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?)

urkle avatar Mar 18 '24 20:03 urkle

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

dbrgn avatar Mar 20 '24 22:03 dbrgn

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.

urkle avatar Mar 21 '24 01:03 urkle

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 avatar Mar 22 '24 18:03 dbrgn

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

dbrgn avatar Jun 02 '24 16:06 dbrgn