# log-genius 🤖💡
**Don't read logs. Understand them.**
`log-genius` is a smart CLI tool that uses AI to analyze and explain complex logs. Stop deciphering cryptic error messages and get human-readable summaries, potential causes, and actionable solutions directly in your terminal.
[](https://crates.io/crates/log-genius)
[](LICENSE)

---
## Why `log-genius`?
- **⚡️ Instant Clarity:** Turns hundreds of lines of confusing logs into a clear, concise explanation.
- **🎯 Actionable Solutions:** Provides concrete code snippets and configuration changes to fix the problem.
- **🧑💻 For Every Developer:** Whether you're in frontend, backend, or DevOps, `log-genius` speaks your language.
- **Seamless Workflow:** Integrates perfectly with your existing workflow using standard Unix pipes. `docker-compose logs | log-genius` is all you need.
---
## Features
- **AI-Powered Analysis:** Leverages large language models (like GPT-4o) to understand context and provide intelligent solutions.
- **Pipe-Friendly:** Works seamlessly with standard input.
- **File Input:** Analyze saved log files directly: `log-genius error.log`.
- **Readable Output:** Formatted and colorized for maximum readability.
- **Blazingly Fast:** Written in Rust for performance and reliability.
---
## Installation
### Prerequisites
You must have an OpenAI API key. You can get one from the [OpenAI Platform](https://platform.openai.com/).
### 1. Using `cargo` (Recommended)
If you have the Rust toolchain installed, you can install `log-genius` with a single command:
```bash
cargo install log-genius
```
### 2, From Binaries
Download the pre-compiled binary for your operating system from the [Releases](https://github.com/LunaStev/log-genius/releases) page. Unzip it and place it in a directory within your $PATH.
### 3. From Source
1. Clone the repository:
```bash
git clone https://github.com/LunaStev/log-genius.git
cd log-genius
```
2. Build the project:
```bash
cargo build --release
```
3. The executable will be located at `target/release/log-genius`.
---
## Setup
`log-genius` requires your OpenAI API key to function. Set it as an environment variable:
```bash
export OPENAI_API_KEY="sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
```
To make this permanent, add the line above to your shell's configuration file (e.g., `.zshrc`, `.bash_profile`, or `.bashrc`).
Alternatively, you can create a `.env` file in the directory where you run `log-genius` (or in your project's root) with the following content:
```dotenv
# .env
OPENAI_API_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
```
---
## Usage
`log-genius` is designed to be simple and intuitive.
---
## Piping from another command (most common)
Pipe the output of any command that generates logs directly into `log-genius`.
```bash
# Analyze Docker Compose logs
# Analyze Kubernetes pod logs
# Analyze a service's journald logs
---
## Analyzing a file
You can also pass a log file path as an argument.
```bash
log-genius /path/to/your/error.log
```
---
## Contributing
Contributions are welcome! Whether it's a bug report, a feature request, or a pull request, please feel free to get involved. Check out the [CONTRIBUTING.md](CONTRIBUTING.md) file for more details.