Skip to main content

log11

A simple logging library built on top of loguru.

Installation

pip install log11

Quick Start

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 Configuration

Different Output Formats and Sinks

from log11 import Log, TextFormatConfig
import sys

# Clear any existing configuration
Log.clear()

# 1. JSON output to file
Log.add_output(
    name="file_json",
    sink="logs/app.log",
    data_format="json",
    level="INFO"
)

# 2. Plain text output to file
Log.add_output(
    name="file_text",
    sink="logs/app.txt", 
    data_format="text",
    colored=False,
    level="DEBUG"
)

# 3. Colored text output to console
Log.add_output(
    name="console_colored",
    sink=sys.stdout,
    data_format="text",
    colored=True,
    level="INFO",
    text_format_config=TextFormatConfig(
        date=False,
        time=True,
        level=True,
        location=True,
        function=True,
        message=True,
        extras=True
    )
)

# Get logger with all outputs configured
logger = get_logger()

# Log messages - they'll appear in all configured outputs
logger.info("User logged in", user_id=123, username="alice")
logger.debug("Debug information", debug_data={"key": "value"})

Environment-Specific Configuration

from log11 import Log, TextFormatConfig
import sys
import os

# Clear any existing configuration
Log.clear()

if os.getenv("ENV") == "production":
    # Production: JSON to file only
    Log.add_output(
        name="production",
        sink="logs/production.log",
        data_format="json",
        level="INFO"
    )
else:
    # Development: Colored text to console
    Log.add_output(
        name="development",
        sink=sys.stdout,
        data_format="text", 
        colored=True,
        level="DEBUG",
        text_format_config=TextFormatConfig(
            date=False,
            time=True,
            level=True,
            location=True,
            function=True,
            message=True,
            extras=True
        )
    )

logger = get_logger()
logger.info("Environment-specific logging")

## API Reference

### Log

The main logging configuration manager.

- `Log.clear()`: Clear all output configurations
- `Log.default_setup()`: Setup default console logging
- `Log.add_output(name, sink, data_format, colored, level, text_format_config, **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

Release files for log11 0.1.11

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for log11 0.1.11
File Size Uploaded
log11-0.1.11.tar.gz 42.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for log11 0.1.11
File Interpreter ABI Platform
log11-0.1.11-py3-none-any.whl Python 3 none any Details

Total release size: 49.4 kB

Release files / log11-0.1.11.tar.gz

Download URL log11-0.1.11.tar.gz
Size 42.9 kB
Tags Source
SHA-256 checksum
How to use checksums
b4f072fc51023e0a9b7606a4e3b0cafcc7272d0602abec925ec2fcea42cd04ad
BLAKE2b-256 checksum
How to use checksums
f6dfacc6ccb8fb7e1ea9cdd9e9ec1d407dde28f49d552f864adf55359fd7b5d4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Release files / log11-0.1.11-py3-none-any.whl

Download URL log11-0.1.11-py3-none-any.whl
Size 6.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b14f67497afe563a8f491b12b704caa0ccfb2f7a3f5555bd40316059fa2fcf26
BLAKE2b-256 checksum
How to use checksums
631bdd592b211f7e031df583d53f0e26a9d315246c99570139bab5ffe31188de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Release history Release notifications | RSS feed

This release

0.1.11 This release

2 release files

0.1.10

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page