Skip to main content

Interactive command-line tool for parsing, filtering, summarizing, and exporting log files.

Project description

Logan-IQ: Log Analyzer Tool

Version Issues

An interactive command-line tool for parsing, filtering, summarizing, and exporting log files. Designed to handle multiple log formats with custom regex support and user-configurable preferences.

⚠️ Notice About Installation

Version 1.0.1 contains unintended scripts and should not be used.
Please use 1.0.2 or later for correct functionality.

Features

  • Parse logs using regex patterns (default or custom)
  • Filter logs by level, date range, or limit
  • Generate summary tables
  • Export logs to CSV or JSON
  • Interactive CLI
  • Colorful output and clean formatting
  • Easily testable and extensible

Install

Package is available on PyPI

pip install logan-iq

This installs the CLI globally and makes the logan-iq command available in your terminal.

🖥️ Startup

Logan-IQ Startup

How it Works

Core flow:

  1. Load Config or Defaults: Loads user preferences from config.json if it exists. CLI arguments always override the config file. If no file is provided and no config exists, the app prompts the user to specify a file.
  2. Parse Log File:

Each log line is converted into a structured dictionary with fields like datetime, level, message,and optionally ip or other fields depending on the format.

  1. Filter (Optional):

Narrow results by log level, date range, or limit the number of entries displayed.

  1. Analyze or Summarize:

Display logs in a terminal table or generate summary reports.

  1. Export (Optional):

Export filtered data to CSV or JSON for further analysis.

Available Formats

You can supply your own regex directly via CLI or in config.json. Or use the Built-in formats:

  • simple → generic logs with datetime, level and message
2025-08-28 12:34:56 [INFO] Server started: Listening on port 8080
  • apache → Apache access logs (common format)
192.200.2.2 - - [28/Aug/2025:12:34:56 +0000] "GET /index.html HTTP/1.1" 200 512
  • nginx → Nginx access logs (combined format, includes referrer & user-agent)
192.100.1.1 - - [28/Aug/2025:12:34:56 +0000] "GET /index.html HTTP/1.1" 200 1024 "http://example.com" "Mozilla/5.0"
  • json → JSON formatted logs (one object per line)
{
  "datetime": "2025-08-28 12:34:56",
  "level": "INFO",
  "message": "Server started",
  "method": "GET",
  "status": 200,
  "path": "/api/v1/users"
}
  • custom → Any user-defined regex Example (inline via CLI):
python main.py analyze --file logs/app.log --format custom --regex "^(?P<ts>\S+) (?P<level>\w+) (?P<msg>.*)$"

Or define in config.json:

{
  "default_file": "logs/custom_app.log",
  "format": "custom",
  "custom_regex": "^(?P<ts>\\S+) (?P<level>\\w+) (?P<msg>.*)$"
}

Running the CLI

Once installed, commands can be run directly via logan-iq:

  • For Interactive Mode
logan-iq interactive
logan-iq>> analyze --file logs/access.log --format nginx
  • Analyze Logs
logan-iq analyze --file path/to/logfile.log --format apache
  • Custom Regex
logan-iq analyze --file app.log --format custom --regex "^(?P<ts>\\S+) (?P<msg>.*)$"
  • Summarize Log Levels
logan-iq summarize --file path/to/logfile.log
  • Export Logs
logan-iq export --file path/to/logfile.log --output-format csv --output-path logs.csv

Configuration

On installation, a config.json is created on the user's system.

  • To show configurations
logan-iq interactive
logan-iq>> config show
  • To modify configurations
logan-iq>> config set --default-file logs/access.log --format nginx
logan-iq>> config set --format custom --custom-regex "^(?P<ts>\\S+) (?P<msg>.*)$"

Example with built-in format:

{
  "default_file": "logs/server_logs.log",
  "format": "nginx"
}

Example with custom format:

{
  "default_file": "logs/app.log",
  "format": "custom",
  "custom_regex": "^(?P<ts>\\S+) (?P<msg>.*)$"
}
  • CLI args always override config values.

  • If neither CLI args nor config exist, the app prompts for a file.

Deleting configuration entries

You can delete configuration entries using the config delete command.

  • Delete a single key:
logan-iq config delete default_file
  • Delete all keys (requires confirmation):
logan-iq config delete all

If you run the command without either --key or --all you'll receive a helpful message explaining the available options.

Dependencies

  • CLI built with Typer
  • Pretty tables via Tabulate
  • Colored output via PyFiglet
  • Unit testing via Pytest

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

logan_iq-1.1.2.tar.gz (17.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

logan_iq-1.1.2-py3-none-any.whl (19.4 kB view details)

Uploaded Python 3

File details

Details for the file logan_iq-1.1.2.tar.gz.

File metadata

  • Download URL: logan_iq-1.1.2.tar.gz
  • Upload date:
  • Size: 17.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for logan_iq-1.1.2.tar.gz
Algorithm Hash digest
SHA256 b2d305648f8ec3402962f26360bc7fb2240451850a659dac5a2d5346cbc56ecf
MD5 2d4553bbf1da2cc8ab59cf60469b7b6f
BLAKE2b-256 211a6338579742cc695f13f01bef1b1ca2c48c54b713680c7605c795313d758c

See more details on using hashes here.

File details

Details for the file logan_iq-1.1.2-py3-none-any.whl.

File metadata

  • Download URL: logan_iq-1.1.2-py3-none-any.whl
  • Upload date:
  • Size: 19.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for logan_iq-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6b5d5afcce2c8383e804d287b659230cb356fc1c5e51e369f418b6cf11f1f0d9
MD5 228c577f97618e7016772d907c8bfc7b
BLAKE2b-256 06bfd744bb6663149e9fc3702fc260e2641247679b625522fd56de18660dc789

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page