top | item 38109646

Show HN: Tailspin – A Log File Highlighter

139 points| bensadeh | 2 years ago |github.com

There are multiple programs for working with log files, both inside and outside of the terminal. These tools are feature rich and functional and offer lots of control to the user.

However, a lot of the time I found myself just opening raw log files in `less`. I enjoy the simplicity of quickly skimming through the logs, but it was difficult when the wall of text was in one color.

For this reason, I created a command line tool called `tailspin` (the name is a take on the `tail` command) that did one thing: highlighting of log files. It is configurable, but requires no setup. It defaults to opening up a file in `less`, but can also work with stdin and stdout.

40 comments

order

mh-cx|2 years ago

Even if it's obvious: I was missing a "How to use" section in the README that demonstrates how this tool can be invoked.

EDIT: Ok, there's something in the "Working with STDIN and STDOUT" section. But TBH I'd find it more helpful to have the different use cases collected at the top. To me it wasn't even clear how the command is called.

cyberge99|2 years ago

I would love to see better performance with triggers. Even on an M1 Pro Max when I have triggers I get a slightly noticeable lag. It could just be me though. I run at 5k resolution with a lot of text.

bensadeh|2 years ago

Thanks for the feedback! Good idea to showcase the use cases earlier and clearer.

joshka|2 years ago

This is really pretty - I do really wish for a good rust replacement for lnav[1] someday.

1: https://lnav.org/

tstack|2 years ago

I also wish for a rust replacement of lnav! (I'm the author)

I actually started working on one earlier this year and made some progress before getting distracted. I was using tui-rs, which then got forked to ratatui. I should check back in with it sometime soon.

swah|2 years ago

Another useful trick is iTerm's Triggers - I use those a bit to find specific strings and store in Airtable or highlight in yellow.

joshka|2 years ago

Yeah - highlighting ERROR as white on red everywhere anywhere is ops gold.

Groxx|2 years ago

You can set up links too! Handy for noticing Jira task IDs and linking them, or (if you work on a single project) GitHub pull request numbers.

kunley|2 years ago

"it requires no configuration or setup", still every single example comes with a config file. WTF?

If you look at it more closely, it can be seen that there is no configuration needed for pattern discovery, but there is for colors. Still, it all together looks a bit dumb. I mean, it's pretty un-marketing to claim something and in the following section do the opposite, even if for a different reason.

I believe this unfortunate working can be fixed.

johnmaguire|2 years ago

This looks really cool! I interact with log files on the command line often. I usually end up using less unless I need better search / highlighting, at which point I bust open vim.

This looks like a great alternative. There was no Homebrew package so I installed Cargo in order to compile it.

Unfortunately, the first log file I tested it on (admittedly quite large at 868M) took 2 minutes and 45 seconds to open in tailspin, pegging a core the entire time. This same file opens instantly with less.

RandomBK|2 years ago

Probably not as efficient, but I've been happily using grc [0] for the past several years. It handles simple rules quite well - beyond the basic info/debug/error coloring I use it for QOL such as different colors for even/odd timestamps and highlighting decimal places in large numbers.

[0] https://github.com/garabik/grc

drcongo|2 years ago

`apt install tailspin` gives me `Unable to locate package tailspin` - Ubuntu 22.04

textcal|2 years ago

Looks pretty for troubleshooting long log files. Thanks for open source it.

tibanne|2 years ago

Is it possible to use this in vscode as a plugin?

thinphp|2 years ago

does this have security issue when hackers injects malicious code into color codes like they mentioned in the Defcon talk?

tamimio|2 years ago

Love it! Thanks for sharing it!

philo23|2 years ago

A little bit off topic, but I’ve always wanted a “simple” CLI tool that works exactly like grep (same flags and regex support), but rather than filtering the result, it just highlights the matches in the output.

I’ve not found anything like that yet though, closest I’ve come is using grep with the before/after/context flag with a high number of lines or using search in less, but I want to do something like...

    tail -f access.log | highlight ".jpg"
Maybe I’ve just not found the right flag for grep yet...

Edit: Thank you everyone for your suggestions, you've all been very helpful! And apologies again for hijacking the topic, tailspin looks very neat.

loudmax|2 years ago

This is how I colorize with grep:

  cat <file> | grep -E --color "<regex>|$"
Where `<regex>` is your pattern.

svedin|2 years ago

ripgrep has a --passthru flag that does exactly this

  tail -f access.log | rg --passthru '\.jpg'