ls

LogAnalyzer · Python · DevOps

Boring Python, Calm On-Call: A Stdlib-Only Log Pipeline

No dependencies, four modules, one cron line — how a Python standard-library CLI parses, reports, and archives application logs.

September 11, 2026 · 7 min read

Production systems whisper before they scream, and they whisper into log files nobody reads. LogAnalyzer Pro is a small Python CLI a team of five built to make those whispers legible: parse a log directory, filter by severity, emit a timestamped JSON report, compress the evidence, and prune old reports. No third-party packages — standard library only.

argparse as a contract

The entire interface is four flags, and the entry point reads like a specification:

parser.add_argument("--source", required=True, help="Chemin vers le dossier logs")
parser.add_argument("--niveau", default="ALL", choices=["ERROR", "WARN", "INFO", "ALL"])
parser.add_argument("--dest", default="./backups", help="Dossier de destination des archives/rapports")
parser.add_argument("--retention", type=int, default=30, help="Jours de rétention des rapports")

Required source, constrained choices for severity, sane defaults everywhere else. A CLI that refuses to guess is a CLI operators trust at 3am.

Absolute paths at the door

The first thing the pipeline does is resolve every path to absolute form and verify the source directory exists, failing fast with a clear message on stderr. Relative paths are a whole category of "works on my machine" — eliminating them at the entry point means every later stage can assume solid ground.

One module per job

Four teammates owned four modules: orchestration and arguments, log parsing with statistics and top errors, timestamped JSON report generation, and tar.gz archiving with retention and disk-space checks. The module boundaries matched the team boundaries, so nobody stepped on anyone's code — Conway's law working for us for once.

Retention is a feature

Reports accumulate forever unless something deletes them, so deletion is designed, not improvised: compressed archives, a configurable retention window defaulting to 30 days, and a disk-space check before writing. Storage hygiene belongs in the tool, not in a runbook nobody opens.

Cron does the remembering

The whole pipeline runs itself every Sunday at 03:00 from a single crontab line. Automation that needs a human to remember it is not automation — one line in cron turns a useful script into actual supervision.

Takeaway

Boring technology compounds: argparse, glob, tarfile, json, cron — nothing exotic, everything reviewable by the whole team. The most reliable system in your infrastructure might be the one with zero dependencies.