File following utility written in Rust - follows through rotation, and always starting at the end.
Go to file
Anthony J. Martinez c8b172de6e
Rev to 0.7.0 after updating read & read_and
`TailedFile::read` is public again, and no longer takes a `&File`
as `TailedFile` already has a `Path` that is of use. The method
now checks rotation/truncation, does the read, and returns
`Result<Vec<u8>>` for users who may just want the bytes.

`TailedFile::read_and` now calls `read` and passes the resultant
underlying `&[u8]` to a user defined function that is its only
argument.

Tests updated accordingly.

Update made after discussion with user Thomas Herzog
<@un9l:matrix.org> in https://matrix.to/#/#staart:txrx.staart.one
on 2023-01-12.
2023-01-12 09:38:46 -06:00
src Rev to 0.7.0 after updating read & read_and 2023-01-12 09:38:46 -06:00
.gitignore Add documentation, fix code style in follow method 2021-01-17 14:59:27 +01:00
Cargo.lock Rev to 0.7.0 after updating read & read_and 2023-01-12 09:38:46 -06:00
Cargo.toml Rev to 0.7.0 after updating read & read_and 2023-01-12 09:38:46 -06:00
LICENSE-APACHE Change to dual license 2021-03-25 19:58:57 +01:00
LICENSE-MIT Change to dual license 2021-03-25 19:58:57 +01:00
README.md Add TailedFile::read_and to allow user defined operations after read 2022-12-26 11:41:49 -06:00

README.md

About

staart is tail-like implementation in Rust. The binary expects exactly one argument which is the file to be followed. Tailing of the file starts at the end of the file, and continues from there. If a file is rotated with a new file created with the same name the program will continue following the named file, and not the previous version. In the case of truncation, data are printed from the start of the file.

Binary

staart offers a Rust std-lib only binary crate capable of following a file. If the file is rotated, the new file will be followed. Following will start at the beginning should truncation be detected. Usage is simple:

staart <path/to/file.ext>

The full feature set of tail is not replicated here. staart will always start from the end of the file, and print all subsequently appearing data to stdout. If non-utf8 code points are found an error is printed to stderr.

If the path given to staart does not exist for three open attempts, the application exits with status code 1.

Library

staart can be used as a library exposing methods to the TailedFile struct it creates should there be a need to follow a file from directly within a more complicated application.

Documentation can be found here.

Windows Support

staart will at least run in a Windows environment as of v0.4.0, but the behavior is not identical to the Linux environment for reasons unknown to the developer. Contributions are welcome if someone wishes to fix this.

MSRV

This crate makes use of format strings stabilized in Rust 1.58, as such this is the Minimum Supported Rust Version.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Contact

To discuss features, offer assistance, or get help plese join the project's Matrix room.

Copyright (C) 2020-2021 Anthony Martinez