I maintain Rust-a-Log, a small command-line log viewer written in Rust. It reads recent records, filters them, and follows new writes.
The useful detail is where the line count applies. If you ask for the last 20 errors or warnings, it finds 20 matching records, rather than taking the last 20 lines and discarding everything else.
Try the current source
With Rust installed:
cargo install --git https://github.com/M1chlCZ/Rust-a-Log --locked
rual app.log -e -w -n 20
This shows the last 20 errors or warnings and follows new records. Press Ctrl+C to stop.
For a one-time search:
rual app.log -g timeout --ignore-case --once
You can combine the two:
rual app.log -e -g database -n 5 --once
This prints the last five error records that also contain database. The text filter is literal, not a regular expression.
Why scan backwards?
When you only need recent records, reading the entire file first does unnecessary work. Rust-a-Log scans backwards in 64 KiB blocks until it finds enough matching records. Its memory use depends on the longest record and a small buffer, rather than the total file size.
A rare filter can still require scanning the whole file. There is no search index or cache.
A few limits to know
- Input must be a regular, seekable text file. Stdin, compressed logs, and multiline event grouping are not supported.
- Level filters recognise bracketed labels such as
[ERROR],[WARN], and[INFO]. - Linux and macOS can reopen a renamed or replaced log. On Windows, rename rotation requires restarting the viewer.
- Following uses polling, so a file that is truncated and regrown between checks can lose records.
The README covers the full behaviour and includes an example screenshot. The project is free and MIT-licensed.
I'd welcome feedback on the log formats you use and which filtering or rotation cases are awkward with your current tools. Reproducible examples are especially useful.
This post was prepared with AI assistance from the project's public documentation.
Top comments (0)