Skip to main content

Modern Python logging framework with Rich console output and loguru file logging, featuring advanced display capabilities, configuration management, and a simple typed API.

Project description

Ezplog

PyPI version Python versions PyPI status License CI Docs uv linter type checker tests

Ezplog Logo

ezplog is a modern Python logging framework combining Rich console rendering and loguru file logging with an explicit app/lib compatibility model.

📦 Installation

# With uv (recommended)
uv add ezplog

# With pip
pip install ezplog

Or from source:

git clone https://github.com/neuraaak/ezplog.git
cd ezplog

uv pip install -e .   # uv
pip install -e .      # pip

🚀 Quick Start

from ezplog import Ezpl

# Initialize once in the application entrypoint
ezpl = Ezpl(log_file="app.log", hook_logger=True, hook_printer=True)
printer = ezpl.get_printer()
logger = ezpl.get_logger()

# Console output (Rich formatting)
printer.info("Information message")
printer.success("Operation completed!")
printer.warning("Warning message")

# File logging (loguru)
logger.info("Logged to file")

# Advanced features
printer.wizard.success_panel("Success", "Operation completed")
printer.wizard.table([{"Name": "Alice", "Age": 30}], title="Users")

🎯 Key Features

  • ✅ Singleton Pattern: One global instance for the whole application
  • ✅ Rich Console Output: Colors, panels, tables, JSON, and progress bars
  • ✅ File Logging: Rotation, retention, and compression via loguru
  • ✅ Explicit Compatibility Hooks: Fine control between app mode and lib mode
  • ✅ Configuration Management: Arguments, environment variables, file, and runtime updates
  • ✅ CLI Tools: Commands for logs and configuration
  • ✅ Full Type Hints: Complete typing support for IDEs and linters
  • ✅ Robust Fallbacks: Safe behavior even with problematic message objects

📚 Documentation

Complete documentation is available at neuraaak.github.io/ezplog

Section Description
Getting Started Installation, basic usage, and first steps
Concepts Design rationale, trade-offs, and architecture
API Reference Complete API documentation with examples
CLI Reference Command-line interface guide
User Guides Configuration, development, and testing guides
Examples Practical examples and demonstrations

🧪 Testing

Comprehensive test suite covering unit, integration, and robustness scenarios. Coverage is generated automatically in documentation workflows.

# Install dev dependencies
uv sync --extra dev

# Run all tests
uv run pytest tests/

# Run specific test types
uv run pytest tests/unit/
uv run pytest tests/integration/
uv run pytest tests/robustness/

# With coverage
uv run pytest --cov=src/ezplog --cov-report=term --cov-report=html

See Testing Guide for complete details.

🛠️ Development Setup

For contributors and developers:

# Install in development mode with all dependencies
uv sync --extra dev --extra docs --extra test

# Install pre-commit hooks (code formatting, linting)
uv run pre-commit install

# Run quality checks
uv run ruff check src tests
uv run ty check

Source code uses a src/ layout (src/ezplog).

Git Hooks:

  • pre-commit: Automatically formats and lints code before commit

See Development Guide for full details.

🎨 Main Components

  • Ezpl: Singleton main class for centralized logging management
  • EzPrinter (alias: Printer): Rich-based console output with pattern format
  • EzLogger (alias: Logger): loguru-based file logging with rotation support
  • RichWizard: Advanced Rich display (panels, tables, JSON, progress bars)
  • ConfigurationManager: Centralized configuration management

📦 Dependencies

  • rich>=13.0.0 – Beautiful console output and formatting
  • loguru>=0.7.2 – Modern and powerful file logging
  • click>=8.0.0 – CLI framework

🔧 Quick API Reference

from ezplog import Ezpl, Printer, Logger

ezpl = Ezpl(hook_logger=True, hook_printer=True)
printer: Printer = ezpl.get_printer()
logger: Logger = ezpl.get_logger()

# Console methods
printer.info(), printer.success(), printer.warning(), printer.error()
printer.tip(), printer.system(), printer.install()  # Pattern methods
printer.wizard.panel(), printer.wizard.table(), printer.wizard.json()

# File logging
logger.info(), logger.debug(), logger.warning(), logger.error()

# Configuration
ezpl.set_level("DEBUG")
ezpl.configure(log_rotation="10 MB", log_retention="7 days")
ezpl.set_compatibility_hooks(hook_logger=True, logger_names=["vendor.payment"])

💻 CLI Usage

The ezpl command provides tools for log inspection and configuration management.

# View recent log entries
ezpl logs view --lines 50

# Search for errors across log files
ezpl logs search --pattern "error|exception" --level ERROR

# Export logs to JSON
ezpl logs export --format json --output logs.json

# Read or update configuration
ezpl config get --show-env
ezpl config set log-level DEBUG

# Open the documentation site
ezpl docs

See the CLI Reference for the full command and option listing.

🛡️ Robustness

Ezpl is designed to never crash, even with problematic input:

  • Automatic string conversion for non-string messages
  • Robust error handling in formatters
  • Safe handling of special characters and Unicode
  • Graceful fallbacks for all error cases

📝 License

MIT License – See LICENSE file for details.

🔗 Links


ezplog - Modern, typed, robust and beautiful logging for Python.

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

ezplog-2.1.8.tar.gz (166.2 kB view details)

Uploaded Source

Built Distribution

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

ezplog-2.1.8-py3-none-any.whl (83.3 kB view details)

Uploaded Python 3

File details

Details for the file ezplog-2.1.8.tar.gz.

File metadata

  • Download URL: ezplog-2.1.8.tar.gz
  • Upload date:
  • Size: 166.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for ezplog-2.1.8.tar.gz
Algorithm Hash digest
SHA256 7b8b9bb7a09d9d72d04014fcb95d779a887efd320f9236cb82e5dbac9f6a6b06
MD5 f9fd7aa7e68459492756362170d9a9f9
BLAKE2b-256 3562234951970c94f2eb3083399e065b08b8d2e35589fc730029c384f14d60db

See more details on using hashes here.

File details

Details for the file ezplog-2.1.8-py3-none-any.whl.

File metadata

  • Download URL: ezplog-2.1.8-py3-none-any.whl
  • Upload date:
  • Size: 83.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for ezplog-2.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 9d96b1b3bd2ff04b9b928e94a537f8cbe0394b43f868fa3dc81a89dc8f8f3fd7
MD5 8a05c484e6fd94a3193693861c05b7be
BLAKE2b-256 4e7c799ec392f4892a04e444cc9880e9d3707c09d95c554c5c7be9315c977281

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