pub struct TestLogger { /* private fields */ }Expand description
Comprehensive test logger that captures typed events with timestamps.
§Example
ⓘ
let logger = TestLogger::new(TestLogLevel::Debug);
// Log events during test
logger.log(TestEvent::TaskSpawn { task_id: 1, name: None });
logger.log(TestEvent::TaskComplete { task_id: 1, outcome: "ok" });
// Generate report
println!("{}", logger.report());
// Assert no busy loops
logger.assert_no_busy_loop(5);Implementations§
Source§impl TestLogger
impl TestLogger
Sourcepub fn new(level: TestLogLevel) -> Self
pub fn new(level: TestLogLevel) -> Self
Creates a new logger with the specified level.
Sourcepub fn level(&self) -> TestLogLevel
pub fn level(&self) -> TestLogLevel
Returns the configured log level.
Sourcepub fn should_log(&self, level: TestLogLevel) -> bool
pub fn should_log(&self, level: TestLogLevel) -> bool
Returns whether the logger should capture events at the given level.
Sourcepub fn event_count(&self) -> usize
pub fn event_count(&self) -> usize
Returns the number of captured events.
Sourcepub fn assert_no_busy_loop(&self, max_empty_polls: usize)
pub fn assert_no_busy_loop(&self, max_empty_polls: usize)
Asserts that the test did not have excessive empty reactor polls (busy loops).
§Panics
Panics if the number of empty polls exceeds max_empty_polls.
Sourcepub fn assert_no_errors(&self)
pub fn assert_no_errors(&self)
Sourcepub fn assert_all_tasks_completed(&self)
pub fn assert_all_tasks_completed(&self)
Asserts that all spawned tasks completed.
§Panics
Panics if any spawned task did not have a corresponding completion event.
Trait Implementations§
Source§impl Debug for TestLogger
impl Debug for TestLogger
Auto Trait Implementations§
impl !Freeze for TestLogger
impl !RefUnwindSafe for TestLogger
impl Send for TestLogger
impl Sync for TestLogger
impl Unpin for TestLogger
impl UnsafeUnpin for TestLogger
impl UnwindSafe for TestLogger
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, _span: NoopSpan) -> Self
fn instrument(self, _span: NoopSpan) -> Self
Instruments this future with a span (no-op when disabled).
Source§fn in_current_span(self) -> Self
fn in_current_span(self) -> Self
Instruments this future with the current span (no-op when disabled).