Menu

Post image 1
Post image 2
Post image 3
1 / 3
0

jq chokes on real-world log streams. So I built a tiny tool that doesn't.

DEV Community·benjamin·3 months ago
#CHIR8Rgj
#dev#fullscreen#json#level#logtidy#photo
Reading 0:00
15s threshold

If you've ever piped a dev server's output into jq to make the JSON logs readable, you know this dance: npm run dev | jq Enter fullscreen mode Exit fullscreen mode { "level" : 30 , "msg" : "server started" , ... } jq: error (at <stdin>: 0 ): Cannot index string with "level" Enter fullscreen mode Exit fullscreen mode It worked for exactly three lines — until your app printed a startup banner, or a plain console.log , or a stack trace. jq hit one line that wasn't valid JSON and aborted the entire stream . Now you're back to reading raw JSON with your eyeballs. The thing is, real log output is never pure JSON. It's a mix: structured lines from your logger (pino, winston, structlog, zap…), plus framework noise, plus whatever you print() -debugged at 2am. Any tool that demands the whole stream be JSON is the wrong tool for an actual terminal. So I built logtidy — a zero-dependency CLI that pretty-prints the JSON lines and passes everything else through untouched.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More