pub async fn watch_log<P: AsRef<Path>>(
path: P,
separator: Option<String>,
) -> Result<impl Stream<Item = Result<String>>>Expand description
Creates a stream that watches a file for new content.
§Arguments
path- File path to monitorseparator- Content separator (defaults to newline)
§Example
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(line) = stream.next().await {
println!("New content: {}", line?);
}
Ok(())
}