0.1.0-0-pre.4
This commit is contained in:
13
crates/common/game-logging-lib/src/test_support.rs
Normal file
13
crates/common/game-logging-lib/src/test_support.rs
Normal file
@@ -0,0 +1,13 @@
|
||||
// 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;
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user