Skip to main content

Stylish console logger with colors, spinner, and progress

Project description

aizenx

A stylish, production-ready Python console & file logger with colors, spinners, progress bars, and more.


Installation

# Without colors (zero dependencies)
pip install aizenx

# With color support (recommended)
pip install aizenx[colors]

Quick Start

from aizenx import log

log.info("Application started")
log.success("Connected to database", "postgres://localhost/mydb")
log.warning("Cache miss rate is high", "redis")
log.error("Request failed", "api.example.com")
log.critical("Out of memory!")

Features

Feature Description
9 log levels DEBUG, INFO, SUCCESS, WARNING, ERROR, CRITICAL, WAIT, DONE, INPUT
Level filtering Only emit records at or above a configured minimum level
File logging Auto-rotating log files via RotatingFileHandler
JSON mode Structured JSON output for log aggregators (ELK, Loki, etc.)
Webhook alerts HTTP POST to a URL when ERROR/CRITICAL events fire
Thread safety All console writes go through a threading.Lock
Spinner Animated spinner context manager for long operations
Progress bar ASCII in-place progress bar
Banners & headers Styled section breaks and title blocks
Interactive prompts input(), confirm(), choice() with consistent styling
Colorama optional Works without colorama – no crash, just no ANSI colors

Usage Examples

Basic logging

from aizenx import log

log.debug("Cache lookup", "users:42")
log.info("Server listening on :8080")
log.success("Payment processed", "order_9921")
log.warning("Retrying in 5 s", "smtp.mailer")
log.error("DB write failed", "orders_table")
log.critical("Filesystem full!")

Custom Logger instance

from aizenx import Logger

log = Logger(
    level="INFO",           # filter out DEBUG records
    log_file="app.log",     # write to rotating file
    use_colors=True,        # False for plain text
    show_timestamp=True,
    show_level=True,
    json_mode=False,        # True → every line is a JSON object
    max_bytes=10_000_000,   # 10 MB per log file
    backup_count=5,
    webhook_url="https://hooks.slack.com/...",  # optional
    webhook_level="ERROR",  # minimum level to trigger webhook
)

log.success("Logger configured", "app")

JSON mode (for log aggregators)

from aizenx import Logger

log = Logger(json_mode=True)
log.info("user login", "auth")
# → {"timestamp": "2024-01-15T10:23:45.123456", "level": "INFO", "message": "user login", "context": "auth"}

Spinner (async indicator)

from aizenx import log
import time

with log.spinner("Fetching data from API", "github"):
    time.sleep(2)           # your blocking work here
# → spinner animates, then prints SUCCESS line on exit

Progress bar

from aizenx import log
import time

for i in range(101):
    log.progress(i, 100, "Uploading")
    time.sleep(0.02)

Banners and headers

log.header("MY APP", "v2.0.1 — production")
log.section("Database migrations")
log.banner(["Status: ONLINE", "Uptime: 3d 4h 12m"])

Interactive prompts

name = log.input("Enter your username")
if log.confirm("Enable verbose mode?", default=False):
    log.info("Verbose mode ON")

idx = log.choice("Select environment", ["development", "staging", "production"], default=2)

Webhook alerts

log = Logger(
    webhook_url="https://hooks.slack.com/services/T.../B.../xxx",
    webhook_level="ERROR",   # fires for ERROR and CRITICAL
)
log.error("Payment gateway timeout", "stripe")
# → silently POSTs JSON payload in a background thread

API Reference

Logger(...) constructor

Parameter Type Default Description
level str "DEBUG" Minimum log level to emit
log_file str | None None Path to rotating log file
use_colors bool True Enable ANSI colors (requires colorama)
show_timestamp bool True Prepend HH:MM:SS.mmm to each line
show_level bool True Show level badge
json_mode bool False Output structured JSON instead of text
max_bytes int 5_242_880 Max log file size before rotation
backup_count int 3 Number of backup files to keep
webhook_url str | None None HTTP endpoint for alert POSTs
webhook_level str "ERROR" Minimum level to fire webhook

Level priority (for filtering)

DEBUG(10) < INFO(20) = SUCCESS(25) < WARNING(30) < ERROR(40) < CRITICAL(50)

License

MIT © aizenx contributors

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

aizenx-0.1.3.tar.gz (12.5 kB view details)

Uploaded Source

Built Distribution

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

aizenx-0.1.3-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

Details for the file aizenx-0.1.3.tar.gz.

File metadata

  • Download URL: aizenx-0.1.3.tar.gz
  • Upload date:
  • Size: 12.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.0

File hashes

Hashes for aizenx-0.1.3.tar.gz
Algorithm Hash digest
SHA256 98833cb12f0e34352a066372e96050aaed993fb643727a24682097f7b5c03d89
MD5 7cb948513b19a5be501827de902e8bf7
BLAKE2b-256 70cf3a61641c833afa0cfea8df2d65307ecc0bfe969a52ce90fa64903128a20c

See more details on using hashes here.

File details

Details for the file aizenx-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: aizenx-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 11.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.0

File hashes

Hashes for aizenx-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 621ccbcc05971b8034e46b39aa35f51e6e9fcc76010ee0148a8ff0d1412cb80c
MD5 412a5977904a53e25a21672f78eb3cad
BLAKE2b-256 5622e1a5d1304496a250e2f0ff9be258fc30670fa0a26cf9fe0d524796529869

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