Skip to content

andraokta/loglens

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LogLens

Fast local log analyzer and error detector — zero dependencies beyond rich and click.

Python CI License Coverage

Why LogLens?

Reading logs with grep is fast when you know what you're looking for. But grep doesn't show you the health of the log as a whole — how many errors, what levels are present, the time range, or a health score.

LogLens gives you both: a rich terminal table for humans, and machine-readable JSON output for pipelines.

LogLens — app.log
┌─────────┬───────┐
│ Level   │ Count │
├─────────┼───────┤
│ INFO    │     2 │
│ ERROR   │     1 │
│ WARNING │     1 │
│ FATAL   │     1 │
└─────────┴───────┘
  Total lines      5
  Errors detected  2
  Health score     60.0%
  Time range       2026-07-26 12:00:00 → 2026-07-26 12:04:00

Quick start

pip install loglens
loglens /var/log/application.log

Or from source:

git clone https://github.com/andraokta/loglens.git
cd loglens
uv sync
uv run loglens path/to/your/logfile.log

Formats

Format Example
ISO timestamp + level 2026-07-25 20:45:12 ERROR database timeout
ISO 8601 with ms 2026-07-25T20:45:12.123Z WARNING cpu > 85%
Bare level-detected INFO server started

Levels detected: FATAL, CRITICAL, ERROR, WARNING, INFO, DEBUG, TRACE

CLI

# Rich terminal table
loglens app.log

# JSON for pipelines
loglens app.log --json

# Only error/critical/fatal lines
loglens app.log --errors-only

JSON output

{
  "file": "app.log",
  "total_lines": 5,
  "levels": {"INFO": 2, "ERROR": 1, "WARNING": 1, "FATAL": 1},
  "error_count": 2,
  "health_score": 60.0,
  "first_timestamp": "2026-07-26 12:00:00",
  "last_timestamp": "2026-07-26 12:04:00"
}

API

LogLens can be used as a Python library:

from loglens.parser import parse_line
from loglens.detector import ErrorDetector
from loglens.stats import LogStats

entries = [parse_line(line) for line in open("app.log")]
detector = ErrorDetector()
print(f"Errors: {len(detector.errors(entries))}")
print(f"Health: {detector.health_score(entries):.1f}%")
print(LogStats.from_entries(entries))

Development

uv sync --extra dev
uv run ruff check . && uv run ruff format --check .
uv run pytest --cov=loglens --cov-report=term-missing
uv build

License

MIT © 2026 Andra Dwi Okta Ramadhan

About

Fast local log analyzer and error detector with rich terminal output and JSON mode.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages