Skip to main content

LogLens

A streaming log-file analyzer for Python. Point it at a log file (plain or .gz) and get level breakdowns, top errors/warnings, minute/hour/day timelines, source stats, statistical anomaly detection, and a Rich terminal report either as a library or from the command line.

Status: early / incomplete. This README only documents the parts that are actually implemented today. See What's not finished yet.

Install

Not yet published to PyPI. Install locally from the project directory:

pip install -e .

(or pip install . for a normal, non-editable install)

Command line

loglens app.log                          # one-page summary
loglens app.log --full                   # full report: timeline, sources, samples...
loglens app.log --timeline               # timeline-only view
loglens app.log --level ERROR --level CRITICAL
loglens app.log --pattern "database"     # only lines matching a regex
loglens app.log --from 2026-08-22 --to "2026-08-22 12:00:00"
loglens app.log --json out.json          # also dump the full result as JSON
loglens app.log --no-anomalies           # skip anomaly detection
loglens app.log --no-progress            # disable the progress bar

Run loglens --help for the full list of options.

Library

from loglens import LogAnalyzer, AnomalyDetector, ReportGenerator

result = LogAnalyzer().analyze("app.log")
result.anomalies = [a.to_dict() for a in AnomalyDetector().detect(result)]

ReportGenerator().print_summary(result)   # or print_full_report(result)

print(result.error_rate)        # % of parsed lines that were ERROR/CRITICAL
print(result.summary_stats)     # compact dict of the headline numbers
result.to_dict()                # full, JSON-serializable result

Supported log formats are auto-detected line by line: ISO-8601 / Python logging-style application logs, Apache combined log format, Nginx error logs, and syslog. You can also pass a custom compiled regex with level, time and message named groups to LogParser(custom_pattern=...) for anything else.

Logging helper

from loglens import get_logger

log = get_logger("etl")
log.info("starting run")

Attaches a console handler plus a rotating, gzip-compressing file handler (./logs/<name>.log) - see loglens.constants.config for the defaults.

What's implemented

  • loglens.parser - LogParser, LogEntry, LogLevel: streaming, multi-format parsing
  • loglens.analyzer - LogAnalyzer, AnalysisResult: aggregation & stats
  • loglens.anomalies - AnomalyDetector, Anomaly: z-score spikes, IQR outliers, silence gaps, error bursts
  • loglens.reports - ReportGenerator: Rich terminal reports
  • loglens.logger / loglens.rotation - configurable logging with compressed rotation
  • loglens.exceptions - ApplicationException
  • loglens.cli - the loglens command above

What's not finished yet

These modules exist as placeholders in the source tree but have no implementation, and are not exposed from import loglens:

  • loglens.exporters - JSON/CSV/HTML export helpers (use result.to_dict() + json.dump for now, or loglens --json)
  • loglens.frames - pandas bridge
  • loglens.decorators - instrumentation decorators for data-science code

License

Apache-2.0 - see LICENSE.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

peeklog-0.1.0.tar.gz (32.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

peeklog-0.1.0-py3-none-any.whl (37.6 kB view details)

Uploaded Python 3

File details

Details for the file peeklog-0.1.0.tar.gz.

File metadata

  • Download URL: peeklog-0.1.0.tar.gz
  • Upload date:
  • Size: 32.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.10.19

File hashes

Hashes for peeklog-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4a40dad4e1dfab1e0b4aa132d779b62e64842add12434b17959d46eba37cdcbb
MD5 ee671821f9e8a2604a778cf45891ba71
BLAKE2b-256 8f03982e2c06ff2c65344091e1b9edda39458ec3be443ee88a5a971e4b5121f4

See more details on using hashes here.

File details

Details for the file peeklog-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: peeklog-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 37.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.10.19

File hashes

Hashes for peeklog-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9ef6129419790915bc76317989b9debb92aa46f7478e38b8d8c0bbb3bf1d8649
MD5 dd0ddb9702039680553f0402229395b4
BLAKE2b-256 b793febec12893a48a5e6cc02b0a679c210a30ee6c860bdeb97f71fe9b05cc13

See more details on using hashes here.

Release history Release notifications | RSS feed

1.0.0

2 files

This release

0.1.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page