There's a project called toolong that allows you to easily and quickly navigate log files from your terminal. It's great for JSONL files but it's also useful for most line-delimted formats.
You can install it via pip
:
python -m pip install toolong
And you can run it from the terminal via:
tl
Tailing
One extra neat feature is the ability to see logs update as they come in.
To run that as a demo yourself you can run this script, which adds random
data into a log.txt
file.
import json
import time
import random
while True:
time.sleep(0.4)
d = {"key": random.choice("abcde"), "value": random.random()}
with open("logs.txt", "a+") as f:
f.writelines([json.dumps(d) + "\n"])
And then you can see the new data come in via:
tl logs.txt
Back to main.