pub struct LogConsumer { /* private fields */ }Expand description
Write data to local log files, one JSON object per line, for later ingestion with LogBus or another transfer tool.
This is the Rust counterpart of the Go SDK’s TDLogConsumer. Files are
named {directory}/{prefix.}log.{date} (or ..._{n} when size-based
paging is enabled) and are opened in append mode, so restarting the
process never overwrites existing data.
Implementations§
Source§impl LogConsumer
impl LogConsumer
Sourcepub fn new(directory: &str) -> Result<Self>
pub fn new(directory: &str) -> Result<Self>
Create a consumer writing daily-rotated logs into directory.
Sourcepub fn with_rotate_mode(
directory: &str,
rotate_mode: RotateMode,
) -> Result<Self>
pub fn with_rotate_mode( directory: &str, rotate_mode: RotateMode, ) -> Result<Self>
Create a consumer with an explicit RotateMode.
Sourcepub fn with_go_rotate_mode(directory: &str, rotate_mode: i32) -> Result<Self>
pub fn with_go_rotate_mode(directory: &str, rotate_mode: i32) -> Result<Self>
Numeric rotate-mode constructor matching the Go SDK’s
NewLogConsumer(directory, rotateMode): 0 selects daily rotation,
1 hourly rotation.
Sourcepub fn with_config(config: LogConsumerConfig) -> Result<Self>
pub fn with_config(config: LogConsumerConfig) -> Result<Self>
Create a consumer from a full configuration.
Trait Implementations§
Source§impl Clone for LogConsumer
impl Clone for LogConsumer
Source§impl Consumer for LogConsumer
Available on crate feature blocking only.
impl Consumer for LogConsumer
blocking only.Source§fn add(&self, data: &Data) -> Result<()>
fn add(&self, data: &Data) -> Result<()>
Serialize and append the event, awaiting the writer task’s result.
Unlike the Go SDK — which only admits events onto a channel and
reports write errors from flush/close — this port reports file
errors immediately.
Source§fn flush(&self) -> Result<()>
fn flush(&self) -> Result<()>
Sync the current file to disk and return the first retained error.