7000pctAUTO 55304fd609
Some checks failed
CI / test (3.10) (push) Failing after 4m51s
CI / test (3.11) (push) Failing after 4m54s
CI / test (3.12) (push) Failing after 4m54s
CI / test (3.9) (push) Failing after 4m51s
CI / lint (push) Failing after 4m47s
CI / build (push) Has been skipped
fix: add --version option to Click CLI group
- Added @click.version_option decorator to main() in commands.py
- Imported __version__ from loglens package
- Resolves CI build failure: 'loglens --version' command not found
2026-02-02 09:25:18 +00:00
2026-02-02 08:08:57 +00:00

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

  1. Clone the repository:

    git clone https://github.com/yourusername/loglens-cli.git
    cd loglens-cli
    
  2. Install development dependencies:

    pip install -e ".[dev]"
    
  3. Run tests:

    pytest tests/ -v
    

License

MIT License

Description
A CLI tool that parses, analyzes, and provides intelligent summaries of log files
Readme MIT 255 KiB
2026-02-02 08:09:08 +00:00
Languages
Python 100%