| Crates.io | loglens-core |
| lib.rs | loglens-core |
| version | 0.1.3 |
| created_at | 2025-11-20 10:48:56.136112+00 |
| updated_at | 2025-11-21 15:05:36.607599+00 |
| description | A lightning-fast, structured log parsing and query engine (JSON/Logfmt). Powers the LogLens CLI. |
| homepage | https://getloglens.com |
| repository | https://github.com/Caelrith/loglens-core |
| max_upload_size | |
| id | 1941782 |
| size | 45,093 |
The lightning-fast, structured log parsing engine built in Rust.
loglens-core is a high-performance library designed to parse, query, and analyze structured logs (JSON, Nginx, Logfmt) at scale. It powers the LogLens CLI.
level == "error" && latency > 500.Add this to your Cargo.toml:
[dependencies]
loglens-core = "0.1.0"
Here is how you can use loglens-core to parse a log line and run a structured query against it:
use loglens_core::{evaluate, LogEntry, parsers::parse_log_line};
fn main() {
// A sample JSON log line
let log_line = r#"{"level": "error", "latency": 502, "msg": "Database timeout", "timestamp": "2023-10-27T10:00:00Z"}"#;
// 1. Parse the raw string into a structured LogEntry
// This automatically detects if it is JSON or Logfmt
let entry = parse_log_line(log_line);
// 2. Define a query
// Returns true if latency is greater than 500 AND level is "error"
let query = "latency > 500 && level is error";
// 3. Evaluate the query against the parsed entry
if let LogEntry::Structured(value) = entry {
// 'evaluate' returns a Result<bool, QueryError>
match evaluate(&value, log_line, query) {
Ok(true) => println!("✅ Match found!"),
Ok(false) => println!("❌ No match."),
Err(e) => eprintln!("Query error: {}", e),
}
} else {
println!("Could not parse as structured log.");
}
}
This library is the engine behind LogLens, a terminal-based log explorer that replaces jq and tail -f with a powerful TUI.
LogLens Pro features:
loglens watch).brew tap Caelrith/loglens
brew install loglens
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License.