Skip to content

crd3cc04/python-log-file-analyzer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🐍 Python Log File Analyzer

A lightweight Python script that scans log files and generates a summary of INFO, WARNING, and ERROR messages. This project demonstrates practical automation skills used in IT, DevOps, and cybersecurity environments.


πŸš€ Features

  • Counts INFO, WARNING, and ERROR messages
  • Extracts and analyzes error messages
  • Identifies the most common error
  • Fully tested with pytest

πŸ“ Project Structure

python-log-file-analyzer/
β”‚
β”œβ”€β”€ src/
|   β”œβ”€β”€ init.py
β”‚   └── log_analyzer.py
β”‚
β”œβ”€β”€ sample_logs/
β”‚   └── system.log
|
β”œβ”€β”€ tests/
|   └── test_log_analyzer.py
|
β”œβ”€β”€ conftest.py
β”‚
└── README.md

▢️ How to Run

From the project root:

python3 src/log_analyzer.py

πŸ§ͺ Sample Output

===== Log File Summary =====
Total INFO messages: 3
Total WARNING messages: 1
Total ERROR messages: 2

Most common error: 'Backup process failed' occurred 1 times

πŸ§ͺ Running Tests

To run the full test suite:

pytest -v

πŸ“˜ Sample Log Format

2024-06-01 12:00:00 INFO User logged in
2024-06-01 12:00:00 ERROR Something broke

Malfromed lines are automatically detected and marked as:

level = 'UNKNOWN"
timestamp = None

πŸ“Œ Why This Project Matters

This script demonstrates:

  • Python automation
  • Log parsing
  • Pattern recognition
  • Error analysis
  • Real‑world IT troubleshooting skills

Perfect for showcasing practical scripting ability on a GitHub portfolio.


πŸ”§ Future Enhancements

  • Export results to CSV
  • Add colorized terminal output
  • Support for multiple log formats
  • Regex‑based filtering
  • Add CLI interface
  • Add JSON output option
  • Add summary export to file

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages