hedhyw / json-log-viewer

Interactive viewer for JSON logs.
MIT License
82 stars 7 forks source link

feat: Fast stdin display, lower memory usage, follow/reverse mode, home/end key support. long help support #85

Closed chirino closed 2 days ago

chirino commented 4 weeks ago

Maybe I got a little carried away. It would have been better if this was done over several commits. Feel free to cherry-pick ideas from this PR if you like any of its features.

The main reason I started down this path was that I expected docker logs XXX -f | jlv to behave similarly to tail -f with lo events just showing up as they occurred. With this PR, stdin input is displayed instantly. The log table now has a follow mode which is turned off once you navigate away from the latest log entry so the log entries will stop scrolling past the window.

While at it I noticed that we could optimize memory use by NOT holding log line data in memory. We just need an offset, and length pair for each long line. When the log is displayed we just load it back from the file. Maybe we should increase the default MAX file size setting? Might need some testing to figure out a better default.

If you have a fast log stream, it might be hard to get back into follow mode by pressing the up key enough times to go past the first item, so Home/End key support was added.

And while at it, I reversed log file order and option. pressing r will toggle.

With so many new options, and mode, I added support for long help display. Press ? to show the more advanced key binds.

hedhyw commented 3 weeks ago

I'm still on it, need more time

chirino commented 2 weeks ago

Rebased and applied your suggestions. I'll be able to look into this more next week.

chirino commented 1 week ago

Fixed the linter warnings. Let me know if there are any other bits you want adjusted.

hedhyw commented 1 week ago

the test coverage decreased significantly, I can help with tests here

hedhyw commented 6 days ago

The latest changes don't work for me.

make run

image

commit 88a3750859b5421ad95585ed6fcd894f8134f01f

chirino commented 5 days ago

That break is fixed now.