HN 표시: Lazylogs -TUI 구조화된 로그 뷰어(터미널에 맞게 jq를 충족하지 않음)
hackernews
|
|
💼 비즈니스
#cli
#jq
#tui
#로그뷰어
#터미널
원문 출처: hackernews · Genesis Park에서 요약 및 분석
요약
개발자가 Go 언어와 Bubble Tea를 기반으로 대용량 구조화된 로그를 터미널에서 빠르게 확인할 수 있는 TUI 뷰어 'Lazylogs'를 공개했습니다. 이 도구는 JSON, logfmt 등을 자동 감지하며 로그 레벨 및 시간 필터링 기능을 제공합니다. 배치 처리를 통해 초당 약 55만 개의 JSON 라인을 처리하는 고성능을 자랑하여 대규모 로그 분석에 유용합니다. 또한 kubectl과 호환되는 파이프라인 기능을 지원해 개발자들의 편의성을 높였습니다.
본문
A fast, interactive TUI viewer for structured logs. Think less meets jq -- for your terminal. cat app.log | lazylogs 10:00:00.100 INF server starting version=1.2.0 port=8080 10:00:00.250 INF database connected host=db.internal latency=48ms 10:00:03.500 WRN slow query detected duration=1.2s table=orders 10:00:06.000 ERR failed to send email error=SMTP connection timeout 10:00:07.000 ERR payment gateway error gateway=stripe error=upstream timeout 10:00:15.000 FTL out of memory allocated=4.0GB limit=4.0GB - Auto-detect format -- JSON Lines, logfmt, plain text. No configuration needed. - Color-coded levels -- Errors in red, warnings in yellow, at a glance. - Filter by level -- Press 1 to show only errors. Press0 to reset. - Time range filter -- Press t to filter by time: last 1m, 5m, 15m, 1h, or custom range. - Search -- / to search across all fields. - Custom columns -- --columns time,level,msg,status,latency for aligned table display. - Detail view -- Enter to expand any entry, see all structured fields. - Follow mode -- Auto-scroll to latest entries, like tail -f . - Fast -- Batch processing handles 1M+ lines. ~550K JSON lines/sec on Apple M4. - Pipe-friendly -- Works with kubectl logs ,docker logs ,journalctl , or any command. - Single binary -- No runtime dependencies. Download and run. go install github.com/syasoda/lazylogs/cmd/lazylogs@latest git clone https://github.com/syasoda/lazylogs.git cd lazylogs go build -o lazylogs ./cmd/lazylogs # Read from file lazylogs app.log # Pipe from any command cat app.log | lazylogs kubectl logs -f my-pod | lazylogs docker logs -f my-container 2>&1 | lazylogs journalctl -f | lazylogs stern my-app | lazylogs Display specific fields as an aligned table: lazylogs --columns time,level,msg,status,latency app.log # Short form lazylogs -c time,level,msg,method,path,status app.log TIME LEVEL MSG STATUS LATENCY 10:00:02.120 INF request completed 200 12ms 10:00:02.450 INF request completed 200 8ms 10:00:03.100 INF request completed 201 145ms 10:00:06.000 ERR failed to send email 10:00:07.000 ERR payment gateway error Press t in the TUI to filter by time: | Key | Range | |---|---| 1 | Last 1 minute | 2 | Last 5 minutes | 3 | Last 15 minutes | 4 | Last 1 hour | 5 | Custom range (e.g. 10:00-10:30 ) | 0 | Reset | lazylogs auto-detects the format of each line. You can mix formats in the same stream. Works with any JSON logger -- slog, zap, zerolog, logrus, Bunyan, Pino, etc. {"time":"2025-03-01T10:00:00Z","level":"info","msg":"request completed","status":200,"latency":"45ms"} Auto-detected fields: - Level: level ,lvl ,severity ,log_level - Message: msg ,message ,text ,body - Timestamp: time ,timestamp ,ts ,@timestamp ,t ,datetime ts=2025-03-01T10:00:00Z level=info msg="server started" port=8080 2025-03-01 10:00:08 ERROR failed to process payment Level is detected from common keywords (ERROR , WARN , INFO , DEBUG , etc.). | Key | Action | |---|---| j / k / Up / Down | Scroll | PgUp / PgDn / Ctrl+U / Ctrl+D | Half-page scroll | g / G | Jump to top / bottom | Enter | Detail view (show all fields) | / | Search | t | Time range filter | Esc | Clear filter / back | 1 | Toggle error / fatal | 2 | Toggle warn | 3 | Toggle info | 4 | Toggle debug / trace | 0 | Show all levels | f | Toggle follow mode | q / Ctrl+C | Quit | Batch processing with incremental filtering. Handles large log files without re-scanning all entries on every update. BenchmarkParseJSON 558K lines/sec 1689 B/op BenchmarkParseLogfmt 2.9M lines/sec 480 B/op BenchmarkParsePlain 3.4M lines/sec 96 B/op ┌──────────────────────────────┐ stdin/file ──read──>│ parser (JSON/logfmt/plain) │ └──────────┬───────────────────┘ │ chan (batched, up to 1000/16ms) ┌──────────▼───────────────────┐ │ TUI model │ │ ├─ filter by level │ │ ├─ filter by time range │ │ ├─ filter by search │ │ └─ incremental index update │ └──────────┬───────────────────┘ │ ┌──────────▼───────────────────┐ │ view (list / columns / detail) │ └──────────────────────────────┘ - Batch processing for large files - Time range filtering - Custom column display - Tail mode for files ( lazylogs -f app.log ) - Regex search - Export filtered results to file - Themes / color customization - Windows support Contributions are welcome! Please feel free to submit a Pull Request. go test ./... go build -o lazylogs ./cmd/lazylogs ./lazylogs testdata/demo.jsonl MIT License. See LICENSE for details. Built with the excellent Charm libraries: Bubble Tea | Lip Gloss | Bubbles
Genesis Park 편집팀이 AI를 활용하여 작성한 분석입니다. 원문은 출처 링크를 통해 확인할 수 있습니다.
공유