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.
- Counts INFO, WARNING, and ERROR messages
- Extracts and analyzes error messages
- Identifies the most common error
- Fully tested with pytest
python-log-file-analyzer/
β
βββ src/
| βββ init.py
β βββ log_analyzer.py
β
βββ sample_logs/
β βββ system.log
|
βββ tests/
| βββ test_log_analyzer.py
|
βββ conftest.py
β
βββ README.md
From the project root:
python3 src/log_analyzer.py===== Log File Summary =====
Total INFO messages: 3
Total WARNING messages: 1
Total ERROR messages: 2
Most common error: 'Backup process failed' occurred 1 times
To run the full test suite:
pytest -v2024-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
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.
- 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