← Back to Projects
Completed
Backend Development

Log Analyser

Python command-line tool that parses a log file and reports counts per log level and the most frequent error messages.

Log Analyser

Date

March 19, 2026

Objective

Summarize a log file's levels and recurring errors without searching it by hand.

Three modules split parsing, analysis and reporting, with argparse in the entry point.

Challenges

  1. 01Extracting timestamp, level and multi-word message from each line
  2. 02Keeping the log format easy to change

How it was solved

  1. 01Pre-compiled regex with named capture groups, returned as a dict per line
  2. 02The whole format lives in one pattern in parser.py

Results

  • No third-party dependencies: runs on the Python standard library

Overview

Runs from the terminal with the log path as its only argument (python main.py logs/sample.log) and prints the report to standard output.

Technical Implementation

Parsing

parser.py reads the file line by line and matches YYYY-MM-DD HH:MM:SS LEVEL message for INFO, WARNING and ERROR. Lines that don’t match are skipped; a missing file logs a warning and exits.

Analysis

analyzer.py counts entries per level with Counter and ranks ERROR messages with most_common(), top 5 by default.

Reporting

reporter.py prints aligned columns with f-string formatting.

Features

  • Count of entries per log level
  • Top 5 most frequent error messages with occurrence count

Technologies

  • Python 3.10+
  • Regex
  • collections.Counter
  • Argparse

Impact

It turns a raw log file into a count per level and a ranking of the most repeated errors. Nothing to install beyond Python.

Ask my portfolio

AI

I answer from what's published on this site and link the project each answer comes from. If you'd rather talk to Fer, tell me and I'll pass on your details.