Skip to content

MengseuThoeng/logai

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LogAI - Smart CLI Log Analyzer 🔍

This is a submission for the GitHub Copilot CLI Challenge

What I Built

LogAI is an intelligent command-line tool that analyzes log files, detects errors, summarizes issues, and suggests fixes using AI-powered analysis. Built with GitHub Copilot CLI assistance to streamline development and enhance productivity.

Demo

# Analyze a log file
logai analyze app.log

# Explain a specific error
logai explain ERROR_502

# Detect errors in Docker logs
logai detect docker.log

# Get a summary of issues
logai summary backend.log

Features

  • 🔍 Smart Error Detection - Automatically identifies errors, warnings, and critical issues
  • 📊 Issue Summarization - Provides concise summaries of log file problems
  • 💡 Fix Suggestions - AI-powered recommendations to resolve detected issues
  • 🐳 Multi-Format Support - Works with backend logs, Docker logs, application logs, and more
  • Fast Analysis - Quick parsing and pattern matching
  • 🎨 Beautiful Output - Color-coded, readable terminal output

Installation

# Clone the repository
git clone https://github.com/MengseuThoeng/logai.git
cd logai

# Install dependencies
pip install -e .

# Or install directly
pip install logai

Usage

Analyze a log file

logai analyze /path/to/app.log

Explain a specific error code

logai explain ERROR_502
logai explain "Connection timeout"

Detect errors only

logai detect /path/to/logs/error.log

Get a summary

logai summary /path/to/logs/app.log

Watch mode (real-time monitoring)

logai watch /path/to/logs/app.log

How GitHub Copilot CLI Helped

Throughout this project, GitHub Copilot CLI was instrumental in:

  1. Regex Pattern Generation - Creating complex patterns for log parsing
  2. Error Handling - Suggesting robust error handling strategies
  3. CLI Command Structure - Designing intuitive command-line interfaces
  4. Code Optimization - Improving performance of log parsing algorithms
  5. Testing Strategies - Generating test cases for various log formats

Example Copilot CLI Usage

# Used to generate log parsing regex
gh copilot suggest "create regex pattern to match timestamp, log level, and message in log files"

# Used to optimize file reading
gh copilot suggest "efficient way to read large log files in Python without loading entire file in memory"

# Used to design CLI structure
gh copilot suggest "create Click-based CLI with analyze, explain, detect, and summary commands"

Technology Stack

  • Python 3.8+ - Core language
  • Click - CLI framework
  • Rich - Beautiful terminal output
  • Re (Regex) - Pattern matching
  • JSON - Configuration and output formats

Project Structure

logai/
├── logai/
│   ├── __init__.py
│   ├── cli.py              # Main CLI entry point
│   ├── analyzer.py         # Log analysis logic
│   ├── detector.py         # Error detection
│   ├── parser.py           # Log parsing
│   ├── explainer.py        # Error explanation
│   └── patterns.py         # Regex patterns for different log formats
├── tests/
│   ├── test_analyzer.py
│   ├── test_detector.py
│   └── sample_logs/
├── examples/
│   ├── app.log
│   ├── docker.log
│   └── backend.log
├── setup.py
├── requirements.txt
├── LICENSE
└── README.md

Examples

Sample Output

╭─────────────────────────────────────────────────────────╮
│ 📊 LogAI Analysis Report                               │
╰─────────────────────────────────────────────────────────╯

📁 File: app.log
📏 Lines: 1,247
⏱️  Time Range: 2026-01-23 08:00:00 - 2026-01-23 14:30:22

╭─────────────────────────────────────────────────────────╮
│ ⚠️  Errors Detected: 15                                 │
╰─────────────────────────────────────────────────────────╯

🔴 CRITICAL (3):
  • Line 234: Database connection timeout
  • Line 567: OutOfMemory exception
  • Line 891: Authentication service unreachable

🟡 WARNINGS (12):
  • Slow query warnings (8 occurrences)
  • Deprecated API calls (4 occurrences)

╭─────────────────────────────────────────────────────────╮
│ 💡 Suggested Fixes                                      │
╰─────────────────────────────────────────────────────────╯

1. Database Connection Timeout
   → Check connection pool settings
   → Verify database server status
   → Review network connectivity

2. OutOfMemory Exception
   → Increase JVM heap size
   → Check for memory leaks
   → Review application memory usage patterns

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT License - see LICENSE file for details

Author

Mengseu Thoeng - @MengseuThoeng

Built for the GitHub Copilot CLI Challenge 2026


⭐ If you found this useful, please star the repo!

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages