You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have standardized on log as our logging library. The pretty_env_logger (or env_logger for that matter) logs to stderr, but the output file descriptor can be changed at initialization time to stdout. cargo test is supposed to capture all writes to stdout to avoid spam (cargo test -- --nocapture disables this behavior), but this is currently broken (rust-lang/rust#42474), in the context of multi-threaded code.
It would be nice to have logs that can be enabled/disabled for the tests, if only for debugging.
The text was updated successfully, but these errors were encountered:
This seems to work, and I'm using it in the ethereum random beacon test case.
fn try_init_logging() {
// `pretty_env_logger` logs to stderr by default. While it could be
// re-targetted to log to stdout, Rust/Cargo bugs prevent stdout from
// threads being captured, so there's no point.
//
// See: https://github.com/rust-lang/rust/issues/42474
for arg in std::env::args() {
if arg == "--nocapture" {
pretty_env_logger::formatted_builder()
.unwrap()
.filter(None, LevelFilter::Trace)
.init();
return;
}
}
}
Because tests run by cargo test will squelch writes to stdout (well, it will try to, it's kind of broken) unless --nocapture is explicitly specified, in order to keep output readable. I think this is reasonable behavior because "pages and pages of web3 logs for the random beacon test" for example, aren't useful to most people unless they're debugging it.
We have standardized on
log
as our logging library. Thepretty_env_logger
(orenv_logger
for that matter) logs to stderr, but the output file descriptor can be changed at initialization time tostdout
.cargo test
is supposed to capture all writes tostdout
to avoid spam (cargo test -- --nocapture
disables this behavior), but this is currently broken (rust-lang/rust#42474), in the context of multi-threaded code.It would be nice to have logs that can be enabled/disabled for the tests, if only for debugging.
The text was updated successfully, but these errors were encountered: