3 releases (breaking)
0.3.0 | Jan 21, 2025 |
---|---|
0.2.0 | Jan 13, 2025 |
0.1.0 | Jan 11, 2025 |
#73 in Debugging
358 downloads per month
84KB
2K
SLoC
Grits
A simple line-text formatter that makes it simple to parse, filter, and format live logs turning noise into meaningful insights.
An example of Grits in action: the left pane shows Grits being applied, and the right pane displays the raw logs.
At its core, grits
applies regular expressions with named captures to input lines. These captures are then available as variables
(a.k.a. anchors) which can then be used in a grits
template string. The template string supports text-alignment, colorization,
as well as other attributes you'd expect using ANSI escape sequences.
The following example demonstrates how to apply grits
to tcpdump
to extract an output line's timestamp (ts
) and
a packet's source (src
) and destination (dst
) IP address:
tcpdump -nn | grits -- \
-p '^(?<ts>[^ ]+)' \
-p 'IP\w? (?<src>[^ ]+)' \
-p '> (?<dst>[^ ]+):' \
-t '[{(cyan|bold):ts}] {(green|underlined):"src"}={(lalign(45)):src} {(yellow|underlined):"dst"}={dst}'
The top pane in the above screenshot is the raw output of tcpdump while the bottom pane shows the output being piped into grits.
Installation
crates.io
cargo install grits
cURL
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/solidiquis/grits/releases/download/v0.3.0/grits-installer.sh | sh
Powershell
powershell -ExecutionPolicy Bypass -c "irm https://github.com/solidiquis/grits/releases/download/v0.3.0/grits-installer.ps1 | iex"
Manual installation
Check the releases page for prebuilt binaries.
Documentation
The documentation for grits
can be found here. It is also available in the CLI via --help
.
Contributing
All well-intentioned forms of contributions are welcome.
Donating
If you like this tool, please consider buying me a coffee. Much appreciated!
FAQ
-
Q: Have you heard of lnav? Why should I use grits over lnav?
-
A: I have heard of lnav but I haven't used it. Users are encouraged to use both to see what best fits their needs.
-
Q: Why is this called grits?
-
A: I was really craving shrimp & grits while writing this on a plane going to South Korea. Also, checkout my Spotify playlist called Melancholy with a side of Grits.
Dependencies
~6–16MB
~225K SLoC