🛈 Note: This is pre-release documentation for the upcoming tracing 0.2.0 ecosystem.

For the release documentation, please see docs.rs, instead.

Module tracing_mock::event

source ·
Expand description

An ExpectedEvent defines an event to be matched by the mock collector API in the collector 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::collect::with_default;
use tracing_mock::{collector, expect};

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

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

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

handle.assert_finished();

Structs§

Functions§