Skip to content

0.6.1

Compare
Choose a tag to compare
@KodrAus KodrAus released this 07 Mar 03:55
2ae080e

Key Changes

  • Support better capturing for cargo test
  • Don't print internal logs to stdout

Contributions

More Details

Builder::is_test

The is_test method can be used in tests to make sure logs are captured by cargo test the same way println! is:

fn init() {
    let _ = env_logger::builder().is_test(true).try_init();
}

#[test]
fn it_adds_one() {
    init();

    info!("can log from the test too");
    assert_eq!(3, add_one(2));
}

There are performance implications of using is_test though, so it should be avoided outside of unit tests.