pub struct Trace { /* private fields */ }Available on crate feature
tracing only.Expand description
Decorator that enables tracing for tests.
§Examples
use test_casing::{decorate, decorators::Trace};
// Tracing output configuration. Allows to specify the default log directives
// (can be overridden by the `RUST_LOG` env var in the runtime), and to configure
// more concise or pretty output.
static TRACE: Trace = Trace::new("info,test_crate=trace").pretty();
#[decorate(TRACE)]
#[test]
fn some_test() {
// Test logic...
tracing::info!("logging event");
}Implementations§
Source§impl Trace
impl Trace
Sourcepub const fn new(directives: &'static str) -> Self
pub const fn new(directives: &'static str) -> Self
Creates a decorator with the specified directives. The directives can be overridden by the RUST_LOG
env variable in runtime.
Sourcepub const fn global(self) -> Self
pub const fn global(self) -> Self
Sets up the tracing subscriber globally (vs the default thread-local setup). This is only beneficial for multithreaded tests, and may have undesired side effects.
Sourcepub fn create_subscriber(self) -> impl Subscriber + for<'a> LookupSpan<'a>
pub fn create_subscriber(self) -> impl Subscriber + for<'a> LookupSpan<'a>
Creates a subscriber based on the configured params. This is useful in order to reuse Trace
logic in more complex decorators (e.g., ones that capture tracing spans / events).
Trait Implementations§
Source§impl<R> DecorateTest<R> for Trace
impl<R> DecorateTest<R> for Trace
Source§fn decorate_and_test<F: TestFn<R>>(&'static self, test_fn: F) -> R
fn decorate_and_test<F: TestFn<R>>(&'static self, test_fn: F) -> R
Decorates the provided test function and runs the test.
impl Copy for Trace
Auto Trait Implementations§
impl Freeze for Trace
impl RefUnwindSafe for Trace
impl Send for Trace
impl Sync for Trace
impl Unpin for Trace
impl UnwindSafe for Trace
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more