-
Notifications
You must be signed in to change notification settings - Fork 142
Closed
Description
I can't seem to get cargo test to properly capture either STDOUT or STDERR when logging with env_logger. My understanding is that cargo should capture both when tests pass and only show the results when tests fail.
Instead, all logs from env_logger/log macros are interleaved as the tests are running, and none are displayed in the "--- test_name stdout ----" section.
Here's the code I'm using:
extern crate env_logger;
#[test]
fn test_name() -> Result<(), Box<Error>> {
env_logger::init();
println!("PRINTLN"); // gets captured properly
// none of these are captured
error!("error");
info!("info");
trace!("trace");
Err(Box::from("test"))
}
I don't have the same issue using another crate such as simple_logger:
#[test]
fn test_name() -> Result<(), Box<Error>> {
simple_logger::init().unwrap();
println!("PRINTLN");
error!("error");
info!("info");
trace!("trace");
Err(Box::from("test"))
}
dbdr, arnauorriols and martician1
Metadata
Metadata
Assignees
Labels
No labels