Skip to content

borAn77/cpp-log-analyzer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

C++ Log Analyzer

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.


Features

  • 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

Example Log File

INFO Server started
INFO Connection established
WARNING Memory usage high
ERROR Database connection failed
INFO Request processed
ERROR Timeout occurred

Example Output

Total lines: 6
Info: 3
Warnings: 1
Errors: 2

Screenshot

#1 (comment)


How to Compile

Make sure you have g++ installed.

g++ main.cpp -std=c++17 -o log_analyzer

How to Run

./log_analyzer sample_log.txt

On Windows PowerShell:

.\log_analyzer sample_log.txt

What I Learned

  • Basic C++ syntax
  • File input using ifstream
  • Command-line arguments (argc, argv)
  • String searching using find()
  • Compiling C++ programs with g++

Future Improvements

  • Detect additional log levels
  • Export analysis results to a file
  • Add support for large log files
  • Improve CLI interface

Author

Boran Gedik Computer Science Student GitHub: https://github.com/borAn77

About

A simple command-line tool written in C++ that analyzes log files and counts the number of INFO, WARNING, and ERROR messages.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages