| Crates.io | log-reader |
| lib.rs | log-reader |
| version | 0.2.1 |
| created_at | 2025-06-03 02:56:01.09475+00 |
| updated_at | 2025-06-16 02:12:02.29677+00 |
| description | A Rust library for real-time log file monitoring that emits batched content as Vec |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1698613 |
| size | 85,909 |
A Rust library that provides real-time streaming of file contents, monitoring files for changes and emitting new content as an async stream.
Vec<String> for efficient processingwatch_log(path, separator)Creates a stream that watches a file for new content.
path - File path to monitorseparator - Content separator (defaults to newline)Returns a Stream of Vec<String> containing lines from the file.
use log_reader::watch_log;
use tokio_stream::StreamExt;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut stream = watch_log("app.log", None).await?;
while let Some(lines_result) = stream.next().await {
match lines_result {
Ok(lines) => {
println!("Received {} lines:", lines.len());
for (i, line) in lines.iter().enumerate() {
println!(" [{}]: {}", i + 1, line);
}
}
Err(e) => eprintln!("Error: {}", e),
}
}
Ok(())
}
Vec<String>Vec<String>