A blazingly fast terminal-based JSON log viewer with SQL-powered filtering, built in Rust.
β οΈ Disclaimer: This project was created through vibe coding with AI assistance. While it works and is functional, expect some quirks and unconventional patterns. PRs welcome! π¨β¨
- π Fast: Loads all logs into an in-memory DuckDB database for instant filtering
- π SQL Filtering: Use powerful SQL WHERE clauses to filter logs
- β¨οΈ Vim Keybindings: Navigate logs efficiently with familiar vim-style controls
- π¨ Color-Coded Levels: Visual distinction between TRACE, DEBUG, INFO, WARN, ERROR, and FATAL
- π Schema Detection: Automatically detects field types from your JSON logs
- π§ Debug Panel: Built-in tracing debug panel for troubleshooting (toggle with 'L')
- π― Preset Filters: Quick access to common filters (Errors Only, Warnings+, Last Hour)
Install using the automated installer:
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/DanSnow/log-viewer/releases/latest/download/log-viewer-installer.sh | shpowershell -c "irm https://github.com/DanSnow/log-viewer/releases/latest/download/log-viewer-installer.ps1 | iex"Or download pre-built binaries directly from the releases page.
# Install directly from GitHub
cargo install --git https://github.com/DanSnow/log-viewer.gitNote: The first build will take 15-20 minutes due to DuckDB compilation.
# View a JSON log file
log-viewer /path/to/logs.jsonThe viewer works with any JSON-formatted logs, especially those from structured loggers like:
- Pino (Node.js)
- Any logger that outputs JSON lines
Example log format:
{"level":30,"time":1705315425000,"msg":"Server started","hostname":"web-01","pid":12345}
{"level":50,"time":1705315426000,"msg":"Database error","hostname":"web-01","error":"Connection timeout"}j/β- Move down one logk/β- Move up one logg- Jump to first logG- Jump to last logCtrl+d- Scroll down half pageCtrl+u- Scroll up half pageCtrl+f- Scroll down full pageCtrl+b- Scroll up full page
d- Toggle detail panel (shows full JSON)f- Toggle filter panel/- Focus filter inputc- Clear active filterL- Toggle debug logs panel?- Toggle help menuq/Esc- Quit application
1- Apply "Errors Only" filter (level >= 50)2- Apply "Warnings+" filter (level >= 40)3- Apply "Last Hour" filter- Any other key - Start typing custom SQL filter
Enter- Apply current filterEsc- Back to presets / Close panel
The filter panel allows you to write SQL WHERE clauses to filter logs. The viewer automatically detects your log schema and shows available fields with their types.
-- Show only errors
level >= 50
-- Search for specific text
message LIKE '%timeout%'
-- Combine conditions
level >= 40 AND hostname = 'web-01'
-- Time-based filtering (Unix timestamp in milliseconds)
time >= 1705315425000
-- Multiple conditions
level >= 30 AND message LIKE '%database%' AND hostname != 'test-server'The viewer uses Pino-style numeric log levels:
| Level | Number | Description |
|---|---|---|
| TRACE | 10 | Very detailed debugging information |
| DEBUG | 20 | Debugging information |
| INFO | 30 | Informational messages |
| WARN | 40 | Warning messages |
| ERROR | 50 | Error messages |
| FATAL | 60 | Fatal error messages |
The viewer automatically normalizes common field name variations:
msgβmessagelvlβleveltimestampβtime
This means you can use the normalized names in your SQL filters regardless of the original field names in your logs.
The application consists of three main layers:
- Ingestion Layer: Parses JSON log files line-by-line
- Storage Layer: Uses DuckDB for efficient in-memory SQL queries
- Presentation Layer: Ratatui-based TUI with vim-style navigation
- Rust 2024 edition or later
- Cargo
cargo buildcargo testThe application includes tracing for debugging. Press L in the UI to toggle the debug panel, or check stderr for trace output.
- Fast Startup: Logs are loaded and indexed in seconds
- Instant Filtering: SQL queries execute in milliseconds even on large datasets
- Memory Efficient: Uses DuckDB's optimized in-memory storage
If you encounter build issues with DuckDB:
# Clean and rebuild
cargo clean
cargo build --releaseNote: DuckDB compilation takes 15-20 minutes due to the bundled C++ library.
Ensure your log file contains valid JSON lines (one JSON object per line):
# Check your log file format
head -n 5 your-logs.json- Check the debug panel (press
L) for SQL error messages - Ensure field names match your log schema (shown in filter panel)
- Use normalized field names (
message,level,time)
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Export filtered logs to file
- Support for log streaming/tail mode
- Syntax highlighting for SQL filters
- Bookmarks for interesting log entries
- Custom color schemes
- Search within log messages
- Statistics and aggregations view
If you find this tool useful, please consider giving it a β on GitHub!
For bugs and feature requests, please open an issue.