A command-line tool for parsing and visualizing log files. Quickly summarize log levels, view colorized output, or filter for errors — all from the terminal.
- Analyze — counts the total number of
INFO,WARNING, andERRORentries in a log file - View — prints the full log file with color-coded lines by log level
- Errors — filters and displays only
ERRORlines
Output is color-coded using colorama:
| Log Level | Color |
|---|---|
INFO |
Green |
WARNING |
Yellow |
ERROR |
Red |
- Python 3.6+
- colorama
Install the dependency with:
pip install colorama| File | Purpose |
|---|---|
main.py |
CLI entry point — parses arguments and runs commands |
analyzer.py |
Core logic — reads a log file and counts log level occurrences |
python main.py <command> <file>Counts and displays a summary of each log level found in the file.
python main.py analyze path/to/logfile.logExample output:
Log Summary:
INFO: 42
WARNING: 7
ERROR: 3
Prints the entire log file with each line color-coded by its log level. Lines with no recognized level are printed in the default terminal color.
python main.py view path/to/logfile.logFilters the log file and prints only lines containing ERROR.
python main.py errors path/to/logfile.logThe tool detects log levels by scanning each line for the keywords INFO, WARNING, or ERROR. It is compatible with common log formats such as:
2024-01-15 10:23:01 INFO Application started
2024-01-15 10:23:45 WARNING Disk usage above 80%
2024-01-15 10:24:12 ERROR Failed to connect to database
No specific format is enforced — any line containing one of the three keywords will be recognized.
analyzer.pycontains debugprintstatements that log the file path and each line as it is read. These can be removed for production use.- If the specified file does not exist, all commands will print an error message and exit gracefully.