Skip to content

sickagents/loglens

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🔍 loglens

A fast, colorized terminal log file analyzer. Parse, filter, and summarize log files with zero dependencies beyond Python 3.8+.

Features

  • Colorized output — errors in red, warnings in yellow, info in green, debug in gray
  • Pattern matching — grep with regex and context lines
  • Severity detection — auto-detects log levels (ERROR, WARN, INFO, DEBUG, etc.)
  • Statistics summary — line counts, severity breakdown, time range analysis
  • Tail mode — follow log files in real-time (like tail -f but smarter)
  • Multiple formats — auto-detects common log formats (syslog, JSON, Apache, Nginx)
  • Zero dependencies — pure Python, no pip install needed

Installation

git clone https://github.com/sickagents/loglens.git
cd loglens
chmod +x loglens.py

# Optional: add to PATH
ln -s $(pwd)/loglens.py /usr/local/bin/loglens

Usage

Basic Analysis

# Analyze a log file with colorized output
python3 loglens.py /var/log/syslog

# Show only errors and warnings
python3 loglens.py app.log --level ERROR,WARN

# Get statistics summary
python3 loglens.py app.log --stats

Pattern Matching

# Search for a pattern with context
python3 loglens.py app.log --grep "timeout" --context 2

# Use regex patterns
python3 loglens.py app.log --grep "5\d{2}.*timeout"

Real-time Monitoring

# Tail with colorized output and severity filtering
python3 loglens.py /var/log/syslog --follow

# Follow and auto-highlight errors
python3 loglens.py app.log -f --level ERROR

JSON Log Support

# Parse JSON-structured logs (auto-detected)
python3 loglens.py app.json.log

# Specify JSON field mapping
python3 loglens.py app.json.log --json-fields timestamp,message,level

Export

# Export filtered results as JSON
python3 loglens.py app.log --level ERROR --export json

# Export as CSV
python3 loglens.py app.log --stats --export csv

Command Reference

Flag Description
--level, -l Filter by severity: ERROR,WARN,INFO,DEBUG,TRACE
--grep, -g Regex pattern to search for
--context, -c Lines of context around matches (default: 0)
--follow, -f Real-time tail mode
--stats, -s Show statistics summary
--export Export format: json, csv
--json-fields Comma-separated JSON field names for timestamp,message,level
--no-color Disable colorized output
--tail, -t Show last N lines
--since Show entries after this time (ISO 8601 or relative like 1h, 30m)

Log Format Auto-Detection

loglens automatically detects:

  • SyslogJun 15 10:00:00 hostname service[pid]: message
  • Apache/Nginx127.0.0.1 - - [15/Jun/2026:10:00:00 +0000] "GET / HTTP/1.1" 200
  • JSON{"timestamp":"...","level":"error","message":"..."}
  • Python2026-06-15 10:00:00,000 - module - ERROR - message
  • Java/Spring2026-06-15 10:00:00.000 ERROR [thread] class - message
  • Generic — Falls back to severity keyword detection

License

MIT

About

Fast colorized terminal log file analyzer — severity detection, pattern matching, stats, multi-format parsing. Zero dependencies.

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages