Files
games/crates/common/game-logging-lib/src/test_support.rs
2026-09-16 01:01:09 +02:00

14 lines
629 B
Rust

// file: crates/common/game-logging-lib/src/test_support.rs
// version: 1
/// Executes one test body with a thread-local tracing subscriber configured for the Rust test writer.
pub fn with_test_tracing<T>(test_name: &str, operation: impl FnOnce() -> T) -> T {
let subscriber = tracing_subscriber::fmt().with_target(true).with_test_writer().without_time().finish();
return tracing::subscriber::with_default(subscriber, || {
tracing::debug!(test_name = test_name, "test started");
let result = operation();
tracing::debug!(test_name = test_name, "test completed");
return result;
});
}