pub struct LogWriter { /* private fields */ }Expand description
A log writer that produces zstd-compressed JSONL segment files
in a directory, compatible with LogTailer.
Implementations§
Source§impl LogWriter
impl LogWriter
Sourcepub fn write_line(&mut self, line: &str) -> Result<()>
pub fn write_line(&mut self, line: &str) -> Result<()>
Write a JSONL line (record) to the current segment.
If no segment is open, one will be created. After writing,
if the segment has exceeded max_file_size or
max_segment_duration it will be closed and a new segment
will be opened on the next write.
Sourcepub fn write_value<S: Serialize>(&mut self, value: &S) -> Result<()>
pub fn write_value<S: Serialize>(&mut self, value: &S) -> Result<()>
Serialize value to JSON and write it as a JSONL line.
Sourcepub fn maintain(&mut self) -> Result<()>
pub fn maintain(&mut self) -> Result<()>
Flush and close the current segment if it has exceeded
max_segment_duration. This is a no-op if no segment is
open or if the duration has not been exceeded.
Sourcepub fn close(&mut self) -> Result<()>
pub fn close(&mut self) -> Result<()>
Flush and close the current segment, regardless of whether it has exceeded any configured constraints.
Sourcepub fn flush_without_marking_done(&mut self) -> Result<()>
pub fn flush_without_marking_done(&mut self) -> Result<()>
Finish the zstd stream so the data is readable, but do NOT mark the file as done (readonly). This is useful for tests that need to simulate an in-progress segment.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for LogWriter
impl RefUnwindSafe for LogWriter
impl Send for LogWriter
impl Sync for LogWriter
impl Unpin for LogWriter
impl !UnwindSafe for LogWriter
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more