pub struct LogBuffer { /* private fields */ }Expand description
Thread-safe, bounded ring buffer of timestamped log events.
Implementations§
Source§impl LogBuffer
impl LogBuffer
Sourcepub fn new(capacity: usize, enabled: bool) -> Self
pub fn new(capacity: usize, enabled: bool) -> Self
Create a new log buffer with the given capacity and enabled flag.
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Return whether logging is enabled.
Sourcepub fn record(&self, direction: Option<&str>, event: LogEvent)
pub fn record(&self, direction: Option<&str>, event: LogEvent)
Record a typed event with an optional direction.
Sourcepub fn jsonl_snapshot(&self, max_bytes: u64) -> Result<JsonlSnapshot, String>
pub fn jsonl_snapshot(&self, max_bytes: u64) -> Result<JsonlSnapshot, String>
Serialize the buffer to a bounded JSONL snapshot.
Locks the log exactly once for a consistent point-in-time snapshot,
serializes one entry per line with a trailing newline, and checks the
projected size before extending the output (checked arithmetic).
Fails — leaving no output — when the exact snapshot exceeds
max_bytes (the capture per-file quota). The event deque itself is
never cloned and no second full output String is built.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for LogBuffer
impl RefUnwindSafe for LogBuffer
impl Send for LogBuffer
impl Sync for LogBuffer
impl Unpin for LogBuffer
impl UnsafeUnpin for LogBuffer
impl UnwindSafe for LogBuffer
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