pub struct LogRingBuffer { /* private fields */ }Expand description
Bounded ring buffer of log records (oldest are dropped when full).
Implementations§
Source§impl LogRingBuffer
impl LogRingBuffer
Sourcepub fn new(capacity: usize) -> Self
pub fn new(capacity: usize) -> Self
Create a new ring buffer with the given capacity. A capacity of 0 means the buffer is effectively disabled (pushes are no-ops, snapshots are empty).
Sourcepub fn push(&self, record: LogRecord)
pub fn push(&self, record: LogRecord)
Append a record, dropping the oldest one if the buffer is full.
Sourcepub fn snapshot(
&self,
since_ts_ms: Option<i64>,
min_level: Option<&str>,
target_prefix: Option<&str>,
limit: Option<usize>,
) -> Vec<LogRecord>
pub fn snapshot( &self, since_ts_ms: Option<i64>, min_level: Option<&str>, target_prefix: Option<&str>, limit: Option<usize>, ) -> Vec<LogRecord>
Return a filtered, ordered (oldest first) snapshot of buffered records.
§Arguments
since_ts_ms- drop records withtimestamp_ms < since_ts_msmin_level- drop records below this level (TRACE < DEBUG < INFO < WARN < ERROR)target_prefix- drop records whosetargetdoes not start with this prefixlimit- return at most this many records (most recent records win)
Auto Trait Implementations§
impl !Freeze for LogRingBuffer
impl !RefUnwindSafe for LogRingBuffer
impl Send for LogRingBuffer
impl Sync for LogRingBuffer
impl Unpin for LogRingBuffer
impl UnsafeUnpin for LogRingBuffer
impl UnwindSafe for LogRingBuffer
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