A Python logging library
Project description
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
Project details
Release history Release notifications | RSS feed
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.11.tar.gz
(42.9 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file log11-0.1.11.tar.gz.
File metadata
- Download URL: log11-0.1.11.tar.gz
- Upload date:
- Size: 42.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b4f072fc51023e0a9b7606a4e3b0cafcc7272d0602abec925ec2fcea42cd04ad
|
|
| MD5 |
a47116682ed0a82dc213774c153ef143
|
|
| BLAKE2b-256 |
f6dfacc6ccb8fb7e1ea9cdd9e9ec1d407dde28f49d552f864adf55359fd7b5d4
|
File details
Details for the file log11-0.1.11-py3-none-any.whl.
File metadata
- Download URL: log11-0.1.11-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b14f67497afe563a8f491b12b704caa0ccfb2f7a3f5555bd40316059fa2fcf26
|
|
| MD5 |
2968a51ca496dc9178fe03832a08ad5b
|
|
| BLAKE2b-256 |
631bdd592b211f7e031df583d53f0e26a9d315246c99570139bab5ffe31188de
|