I have a crate with production code in the src directory and integration tests in the tests directory. The production code uses log ma
src
tests
log
The latest documentation has a recommendation:
#[cfg(test)] mod tests { fn init() { let _ = env_logger::builder().is_test(true).try_init(); } #[test] fn it_works() { init(); info!("This record will be captured by `cargo test`"); assert_eq!(3, 1 + 2); } }