I think LevelFilter::Off means no filter, i.e. show every level. At least this is how I'd interpret the docs:
Off
A level lower than all log levels.
I think the lowest log level would be Trace and the highest Error. But I could be mixing the direction lowest to highest up. Anyway, I never tried it for myself, so only guesswork anyways.
Thanks for the answers! I changed to LevelFilter::Trace, arg --nocapture seems to be by default there when running a test using the extension.
Is it that the test needs to be over to get the output? I still can't get any and I run into deadlock in my code.
I tried sleeping after a log::debug! as well as a busy loop and in both cases the log output was visible immediately, without waiting for the test to end
#[cfg(test)]
mod tests {
use std::time::Duration;
fn init() {
let _ = env_logger::builder()
.target(env_logger::Target::Stdout)
.filter_level(log::LevelFilter::Trace)
.is_test(true)
.try_init();
}
#[test]
fn test_listen() {
init();
log::debug!("Hi");
std::thread::sleep(Duration::from_secs(10));
}
}
running 1 test
[2023-04-24T17:41:51Z DEBUG main::tests] Hi
test tests::test_listen ... ok
To be clear, the tests were run with rust analyzer in VSCode