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.2.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.2-py3-none-any.whl (11.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: aizenx-0.1.2.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.2.tar.gz
Algorithm Hash digest
SHA256 a6948641e2bfe230faa2720b7a2d7c7262f50fb3e8f3acfebc910ef8e486e5c8
MD5 86f11a2b88ad5a7658d396a7a4deb2d3
BLAKE2b-256 2c0594e45e71e9b5e4eb532f6df6a7f2b1d8e2aa2c0baf4a5cf0904c353a2f9a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: aizenx-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 11.6 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 746b012fab581a57218a4ebd4c263ceae49eee0963b2c9ef73b7c2c99c6bb6ee
MD5 b7e2d7338ad287be06cb3336cbbd0f6a
BLAKE2b-256 329b817e4d7034456d0f9a1e0ca05495984ddce486fa3d98c75341844a493d92

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