pub struct MemoryLogWriter { /* private fields */ }Expand description
In-memory ring buffer for log entries with a configurable capacity.
Once the buffer reaches max_entries the oldest entry is evicted for
every new entry written. This is useful for WASM containers and
short-lived executions where disk I/O is unavailable or undesirable.
Implementations§
Source§impl MemoryLogWriter
impl MemoryLogWriter
Sourcepub fn new(max_entries: usize) -> Self
pub fn new(max_entries: usize) -> Self
Creates a new ring buffer that holds at most max_entries entries.
Sourcepub fn write_entry(&self, entry: LogEntry)
pub fn write_entry(&self, entry: LogEntry)
Pushes an entry into the buffer, evicting the oldest entry if the buffer is at capacity.
§Panics
Panics if the internal mutex is poisoned.
Sourcepub fn write_line(&self, stream: LogStream, message: &str, source: LogSource)
pub fn write_line(&self, stream: LogStream, message: &str, source: LogSource)
Convenience method that constructs a LogEntry with
Utc::now() as the timestamp, then writes it.
Auto Trait Implementations§
impl !Freeze for MemoryLogWriter
impl RefUnwindSafe for MemoryLogWriter
impl Send for MemoryLogWriter
impl Sync for MemoryLogWriter
impl Unpin for MemoryLogWriter
impl UnsafeUnpin for MemoryLogWriter
impl UnwindSafe for MemoryLogWriter
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> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request