Skip to main content

A Python logging library

Project description

log11

A simple logging library built on top of loguru.

Features

  • Modern API: Built on top of the powerful loguru library
  • Flexible Configuration: Multiple output formats (text/JSON)
  • Rich Formatting: Colored output, custom fields, and structured logging
  • Project Root Detection: Automatic project root discovery
  • Python 3.10+: Modern Python features and type hints
  • Zero Configuration: Sensible defaults out of the box

Installation

pip install log11

Quick Start

Basic Usage

from log11 import get_logger

# Get the default logger
logger = get_logger()

# Log messages
logger.info("Application started")
logger.warning("This is a warning")
logger.error("Something went wrong")

Advanced Usage

from log11 import Log, TextFormatConfig

# Setup custom logging configuration
Log.clear()
Log.add_output(
    name="console",
    sink="logs/app.log",
    data_format="json",
    level="INFO",
    text_format_config=TextFormatConfig(
        date=True,
        time=True,
        level=True,
        location=False,
        function=True,
        message=True,
        extras=True
    )
)

# Apply configuration and get logger
logger = Log.apply()

# Log structured data
logger.info("User action", user_id=123, action="login")

Custom Formatting

from log11 import Log, TextFormatConfig, LogColor

# Setup with custom formatting
Log.clear()
Log.add_output(
    name="console",
    sink="stdout",
    data_format="text",
    colored=True,
    level="DEBUG",
    text_format_config=TextFormatConfig(
        date=False,
        time=True,
        level=True,
        location=True,
        function=False,
        message=True,
        extras=True
    )
)

logger = Log.apply()
logger.debug("Debug message with details", debug_info="extra data")

API Reference

Log

The main logging configuration manager.

  • Log.clear(): Clear all output configurations
  • Log.default_setup(): Setup default console logging
  • Log.apply(): Apply all configured outputs and return logger
  • Log.add_output(name, sink, data_format, colored, level, text_format_config, replace, auto_apply, **kwargs): Add a new output configuration
  • Log.add_level(name, number, color): Add a custom logging level
  • Log.set_global_level(level): Set logging level for all outputs

get_logger

  • get_logger(): Get a configured logger instance (sets up defaults if needed)

Configuration Classes

  • TextFormatConfig(date, time, level, location, function, message, extras): Configure text output format
  • TextFormat(config): Text formatter implementation
  • LogColor: Color constants for styling
  • LogStyle: Text styling helpers
  • LogField: Field rendering utilities

Development

Prerequisites

Install uv for modern Python dependency management:

# On Windows (PowerShell)
irm https://astral.sh/uv/install.ps1 | iex

# On macOS/Linux
curl -LsSf https://astral.sh/uv/install.sh | sh

Installation for Development

# Clone the repository
git clone https://github.com/vincentdeneuf/log11.git
cd log11

# Install dependencies and create virtual environment
uv sync

# Activate the virtual environment (optional, uv commands work without it)
source .venv/bin/activate  # On Windows: .venv\Scripts\activate

# Install in development mode
uv pip install -e .

Running Tests

# Run tests with uv
uv run pytest

# Run tests with coverage
uv run pytest --cov=log11 --cov-report=html

Building the Package

# Build the package
uv build

# Build for distribution
uv build --release

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Changelog

0.1.0

  • Initial release
  • Built on loguru for powerful logging capabilities
  • Flexible output configuration (text/JSON formats)
  • Rich formatting with colors and custom fields
  • Project root detection
  • Python 3.10+ support with modern type hints
  • Zero-configuration default setup

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

log11-0.1.9.tar.gz (43.5 kB view details)

Uploaded Source

Built Distribution

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

log11-0.1.9-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file log11-0.1.9.tar.gz.

File metadata

  • Download URL: log11-0.1.9.tar.gz
  • Upload date:
  • Size: 43.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for log11-0.1.9.tar.gz
Algorithm Hash digest
SHA256 b8f348c87eaaa79ecc8b2bad6b840cf442c2e1d6a7fee7d15be31538c7d3e65d
MD5 5d489b95a8d3ad5dc130c6938efbd768
BLAKE2b-256 f5a74ff46d3d51bd30db7940ac3cb47af352e62e01789de5cafe33e475fffde5

See more details on using hashes here.

File details

Details for the file log11-0.1.9-py3-none-any.whl.

File metadata

  • Download URL: log11-0.1.9-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for log11-0.1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 2b18aab1cfd32153893cb6123b4c603f98c08d5c520adea6adc2ec8a60e76a64
MD5 d2c5cfeee4f1626317dea1163dc07514
BLAKE2b-256 3d3fcb249bdaff75b6fa431c65343b685f3824051fce8e09ac8cf81adfbd29f6

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