iroh_test::logging

Function testing_subscriber

Source
pub fn testing_subscriber() -> impl Subscriber
Expand description

Returns the a tracing::Subscriber configured for our tests.

This subscriber will ensure that log output is captured by the test’s default output capturing and thus is only shown with the test on failure. By default it uses RUST_LOG=trace as configuration but you can specify the RUST_LOG environment variable explicitly to override this.

To use this in a tokio multi-threaded runtime use:

use tracing_future::WithSubscriber;
use iroh_test::logging::testing_subscriber;

#[tokio::test(flavor = "multi_thread")]
async fn test_something() -> Result<()> {
   async move {
       Ok(())
   }.with_subscriber(testing_subscriber()).await
}