tracing_mock

Module event

Source
Expand description

An ExpectedEvent defines an event to be matched by the mock subscriber API in the subscriber module.

The expected event should be created with expect::event and a chain of method calls to describe the assertions we wish to make about the event.

§Examples

use tracing::subscriber::with_default;
use tracing_mock::{expect, subscriber};

let event = expect::event()
    .at_level(tracing::Level::INFO)
    .with_fields(expect::field("field.name").with_value(&"field_value"));

let (subscriber, handle) = subscriber::mock()
    .event(event)
    .run_with_handle();

with_default(subscriber, || {
    tracing::info!(field.name = "field_value");
});

handle.assert_finished();

Structs§