A simple command-line tool written in C++ that analyzes log files and counts the number of INFO, WARNING, and ERROR messages.
This project was built to practice C++ fundamentals including file handling, string processing, and command-line arguments.
- Reads a log file line by line
- Detects log levels: INFO, WARNING, and ERROR
- Counts occurrences of each log type
- Displays a summary in the terminal
INFO Server started
INFO Connection established
WARNING Memory usage high
ERROR Database connection failed
INFO Request processed
ERROR Timeout occurred
Total lines: 6
Info: 3
Warnings: 1
Errors: 2
Make sure you have g++ installed.
g++ main.cpp -std=c++17 -o log_analyzer
./log_analyzer sample_log.txt
On Windows PowerShell:
.\log_analyzer sample_log.txt
- Basic C++ syntax
- File input using
ifstream - Command-line arguments (
argc,argv) - String searching using
find() - Compiling C++ programs with
g++
- Detect additional log levels
- Export analysis results to a file
- Add support for large log files
- Improve CLI interface
Boran Gedik Computer Science Student GitHub: https://github.com/borAn77