ADC Logger
A flexible and configurable Python logging library with support for JSON formatting and colored console output.
Features
- JSON Logging: Structured JSON log output with timestamps, log levels, and messages
- Colored Console Output: Beautiful colored logging using
colorlog - Flexible Configuration: Easy-to-use configuration classes for formatters, handlers, and loggers
- Multiple Formatters: Support for JSON, generic colored, and access log formats
- Extensible: Easy to extend with custom formatters and handlers
Installation
pip install -e .
Quick Start
from adc_logger import BaseLoggingConfig
import logging
# Create a custom configuration
config = BaseLoggingConfig()
# Add a logger
from adc_logger.configs import LoggerConfig
config.loggers.append(
LoggerConfig(
name="my_app",
level="INFO",
handlers=["console_json"]
)
)
# Setup logging
config.setup_logging()
# Use the logger
logger = logging.getLogger("my_app")
logger.info("Hello, World!")
Configuration
Formatters
The library provides three built-in formatters:
- JSON Formatter: Outputs structured JSON logs
- Generic Formatter: Colored console output with standard format
- Access Formatter: Simplified format for access logs
Handlers
Built-in handlers include:
console_json: JSON output to consoleconsole_generic: Colored output to consoleconsole_access: Access log format to console
Custom Configuration
You can create custom formatters, handlers, and loggers:
from adc_logger.configs import FormatterConfig, HandlerConfig, LoggerConfig
# Custom formatter
custom_formatter = FormatterConfig(
name="custom",
format="{asctime} - {name} - {levelname} - {message}",
datefmt="%Y-%m-%d %H:%M:%S"
)
# Custom handler
file_handler = HandlerConfig(
name="file_handler",
formatter="json",
class_=logging.FileHandler,
filename="app.log"
)
# Custom logger
app_logger = LoggerConfig(
name="my_app",
level="DEBUG",
handlers=["console_json", "file_handler"]
)
Examples
Basic Usage
from adc_logger import BaseLoggingConfig
import logging
config = BaseLoggingConfig()
config.setup_logging()
logger = logging.getLogger(__name__)
logger.info("Application started")
logger.error("An error occurred")
JSON Logging
from adc_logger import BaseLoggingConfig
from adc_logger.configs import LoggerConfig
import logging
config = BaseLoggingConfig()
config.loggers.append(
LoggerConfig(
name="api",
handlers=["console_json"]
)
)
config.setup_logging()
logger = logging.getLogger("api")
logger.info("API request received", extra={"user_id": 123, "endpoint": "/users"})
Multiple Handlers
from adc_logger import BaseLoggingConfig
from adc_logger.configs import LoggerConfig, HandlerConfig
import logging
config = BaseLoggingConfig()
# Add file handler
file_handler = HandlerConfig(
name="file_handler",
formatter="json",
class_=logging.FileHandler,
filename="app.log"
)
config.handlers.append(file_handler)
# Configure logger with multiple handlers
config.loggers.append(
LoggerConfig(
name="my_app",
handlers=["console_generic", "file_handler"]
)
)
config.setup_logging()
Development
Project Structure
adc_logger/
├── __init__.py # Main exports
├── main.py # BaseLoggingConfig class
├── configs.py # Configuration classes
└── formatters.py # Custom formatters
Dependencies
colorlog>=6.7.0: For colored console output- Python 3.8+
License
MIT License
Metadata
Release files for adc-logger 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| adc_logger-0.1.0.tar.gz | 4.7 kB | Without provenance | Details for adc_logger-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| adc_logger-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for adc_logger-0.1.0-py3-none-any.whl |
Total release size: 9.9 kB
Release files / adc_logger-0.1.0.tar.gz
| Download URL | adc_logger-0.1.0.tar.gz |
|---|---|
| Size | 4.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
69d64541d0e786234998e26b0e14d278c44d5e084fbada5b499798d3e4ef93c3
|
|
BLAKE2b-256 checksum How to use checksums |
b644b4a17ecf240a02ed9c7df577dac820e6ed548178932aa422aed36e7786ac
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.2
|
Release files / adc_logger-0.1.0-py3-none-any.whl
| Download URL | adc_logger-0.1.0-py3-none-any.whl |
|---|---|
| Size | 5.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1f160ef13529312f08428031dd7ac7382694faf25695b0fb5646058ad6846221
|
|
BLAKE2b-256 checksum How to use checksums |
4515f6c88e6174dbcf7c965d6655ffc358d2ebdb2726e3b97e7422a514beac95
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.2
|
Security for adc-logger 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.