tailf 0.1.2

A async `tail -f` for files
Documentation
  • Coverage
  • 86.67%
    13 out of 15 items documented0 out of 11 items with examples
  • Size
  • Source code size: 15.5 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 486.4 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 29s Average build duration of successful builds.
  • all releases: 27s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • kvinwang/tailf
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • kvinwang

tailf

A Rust library that provides an async file tailing functionality using the system's tail command, powered by tokio::process::Command.

Installation

Add this to your Cargo.toml:

[dependencies]
tailf = "0.1.0"

Usage

use tailf::tailf;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Read last 10 lines and follow new updates
    let num_lines = 10;
    let mut tailer = tailf("/var/log/syslog", Some(num_lines));

    while let Some(line) = tailer.next().await? {
        let line_str = String::from_utf8_lossy(&line);
        print!("{}", line_str);
        std::io::stdout().flush()?;
    }

    Ok(())
}

Cleanup

The underlying tail process is automatically terminated when the tailer instance is dropped.

License

This project is licensed under the MIT License - see the LICENSE file for details.