Skip to content

SaneStreet/LogParser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LogParser

A simple Python-based CLI tool that parses and analyzes different types of log files. The tool automatically detects the log format and extracts useful information such as log levels and error counts.

This project is designed as a lightweight log analysis pipeline with modular architecture.


Features

  • Auto-detection of log format
  • Supports real-world log types
  • Parses log entries into a normalized structure
  • Counts log levels (INFO, WARNING, ERROR)
  • CLI-based output for quick diagnostics
  • Modular design for easy extension

Supported Log Formats

Currently the parser can detect ad process:

Application Logs

Example:

2026-03-10 10:04:22 ERROR Database timeout
2026-03-10 10:04:23 WARNING Slow database query

Linux Syslog

Example:

Mar 10 12:11:03 ubuntu kernel: CPU error detected

Web Server Logs

Example:

127.0.0.1 - - [10/Mar/2026:12:11:05 +0000] "POST /login HTTP/1.1" 500 532

HTTP status codes are interpreted as log levels:

  • 2xx --> INFO
  • 4xx --> WARNING
  • 5xx --> ERROR

Project Structure

logparser/
│
├── main.py         - Entry point to the program flow
├── parser.py       - Detects log format, parses log lines, normalizing
├── patterns.py     - RegEx patterns used to identify different log formats
├── analyzer.py     - Processes parsed log entries and generates statistics
└── README.md       - This readme you are reading right now

How It Works

The pipelie follows a simple flow:

Log File
   ↓
Format Detection
   ↓
Line Parsing
   ↓
Normalization
   ↓
Analysis
   ↓
CLI Output

The parser attempts to match each line against known log patterns and extracts structured fields such as:

{
    "timestamp": "...",
    "level": "...",
    "message": "...",
    "source": "..."
}

Usage

Run the parser from the command line and input the name of the logfile:

py main.py

For Windows PowerShell:

py .\main.py

Future Improvements

Potential features that could be added:

  • Top error messages
  • Error grouping / fingerprinting
  • Time-based analysis
  • Support for additional log formats
  • Streaming large log files
  • CLI arguments for filtering

Purpose

This proejct was created as a learning exercise in:

  • Log parsing
  • Regex-based format detection
  • Modular Python design
  • Building CLI developer tools

About

A simple Python-based CLI tool that parses and analyzes different types of log files.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages