ea55f03230259798b11f5cd3542e386e6916692b
Some checks failed
- Added @click.version_option decorator to main() in commands.py - Imported __version__ from loglens package - Resolves CI build failure: 'loglens --version' command not found
LogLens CLI
LogLens is a powerful CLI tool for parsing, analyzing, and summarizing log files. It automatically detects log formats, identifies error patterns, and provides intelligent insights with severity classifications.
Features
- Multi-format Support: Parse JSON, syslog, Apache/Nginx, and raw logs
- Smart Error Detection: Built-in patterns for common error types
- Severity Classification: Categorize issues as critical, error, warning, info, or debug
- Interactive Analysis: Analyze logs interactively or in batch mode
- Rich Output: Beautiful terminal tables with color-coded severity levels
- Flexible Output: Export results as tables, JSON, or plain text
- Pipe Support: Process logs from stdin for real-time analysis
Installation
From Source
pip install -e .
Using pip
pip install loglens-cli
Usage
Basic Analysis
loglens analyze /path/to/logfile.log
Auto-detect Format
loglens analyze /var/log/syslog
loglens analyze /var/log/apache2/access.log
loglens analyze application.json
Specify Format Manually
loglens analyze --format json logs/
loglens analyze --format syslog /var/log/messages
Pipe Support
cat logfile.txt | loglens analyze
grep ERROR system.log | loglens analyze
Watch Files in Real-time
loglens watch /var/log/syslog
loglens watch --interval 5 /var/log/*.log
Generate Reports
loglens report /var/log/*.log --output report.txt
loglens report /var/log/*.log --json
List Available Patterns
loglens patterns
loglens patterns --group exceptions
loglens patterns --severity error
Get Version
loglens --version
Get Help
loglens --help
Options
Global Options
| Option | Description |
|---|---|
-v, --verbosity |
Increase output verbosity (can be used multiple times) |
--config FILE |
Path to a configuration file |
--version |
Show program's version number and exit |
Analyze Command
| Option | Description |
|---|---|
FILES |
Log files to analyze |
--format FORMAT |
Log format: json, syslog, apache, auto (default: auto) |
--output FORMAT |
Output format: table, json, text (default: table) |
--follow/--no-follow |
Follow file changes |
--max-entries N |
Maximum entries to display (default: 100) |
--json/--no-json |
Output as JSON |
Watch Command
| Option | Description |
|---|---|
FILES |
Files to watch |
--format FORMAT |
Log format |
--interval SECONDS |
Refresh interval (default: 1.0) |
--max-entries N |
Maximum entries per update |
Report Command
| Option | Description |
|---|---|
FILES |
Log files to include in report |
--format FORMAT |
Log format |
--output FILE |
Output file path |
--json/--no-json |
Output as JSON |
Supported Log Formats
JSON
{"timestamp": "2023-12-01T10:00:00Z", "level": "error", "message": "Failed to connect to database"}
Syslog
Dec 1 10:00:00 hostname appname[1234]: Error message here
Apache/Nginx
192.168.1.1 - - [01/Dec/2023:10:00:00 +0000] "GET /api HTTP/1.1" 200 1234
Configuration
Create a loglens.yaml file:
verbosity: info
format: auto
output: table
Development
-
Clone the repository:
git clone https://github.com/yourusername/loglens-cli.git cd loglens-cli -
Install development dependencies:
pip install -e ".[dev]" -
Run tests:
pytest tests/ -v
License
MIT License
Releases
1
LogLens CLI v0.1.0
Latest
Languages
Python
100%