#tail #utility #async

bin+lib tailf

A async tail -f for files

3 releases

0.1.2 Nov 18, 2024
0.1.1 Nov 15, 2024
0.1.0 Nov 15, 2024

#17 in #tail

Download history 12/week @ 2025-01-18 2/week @ 2025-01-25 13/week @ 2025-02-01 9/week @ 2025-02-08 16/week @ 2025-02-15 34/week @ 2025-02-22 34/week @ 2025-03-01 22/week @ 2025-03-08 21/week @ 2025-03-15 13/week @ 2025-03-22 32/week @ 2025-03-29 31/week @ 2025-04-05 21/week @ 2025-04-12 16/week @ 2025-04-19 11/week @ 2025-04-26 3/week @ 2025-05-03

55 downloads per month

MIT license

6KB
86 lines

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.

Dependencies

~3–12MB
~125K SLoC