A flexible logging library with support for cloud providers, multi-tenancy, and structured logging
Project description
DC Logger
A flexible, async-first structured logging library for Python with support for multiple handlers, cloud providers, distributed tracing, and multi-tenancy.
Features
- Async-first design - Non-blocking logging for high-performance applications
- Structured logging - JSON-based logs with entities, actions, and context
- Multiple handlers - Console, file, and cloud output simultaneously
- Cloud integrations - Datadog, AWS CloudWatch, GCP, Azure support
- LangSmith observability - Stream structured logs alongside LangChain traces
- Distributed tracing - Built-in correlation with trace/span IDs
- Decorator logging - Automatic function entry/exit logging with
@log_call - Multi-tenant support - Tenant context for SaaS applications
- Colored console output - ANSI colors for better visibility
Installation
pip install dc_logger
# With Datadog support
pip install dc_logger[datadog]
# With LangSmith support
pip install dc_logger[langsmith]
# With all extras
pip install dc_logger[all]
Quick Start
import asyncio
from dc_logger import DCLogger, ConsoleLogConfig, LogLevel
async def main():
config = ConsoleLogConfig(level=LogLevel.INFO)
logger = DCLogger(config, "my_app")
await logger.info("Application started")
await logger.warning("This is a warning")
await logger.error("Something went wrong")
await logger.close()
asyncio.run(main())
Using the Decorator
from dc_logger import log_call
@log_call(action_name="process", include_params=True)
async def process_data(data_id: str):
# Automatically logs entry, exit, duration, and errors
return {"status": "processed"}
Structured Logging with Context
from dc_logger import LogEntity
entity = LogEntity(type="dataset", id="ds_123", name="Sales Data")
await logger.info(
"Dataset processed",
entity=entity,
action="process_dataset",
duration_ms=1500,
extra={"rows": 10000}
)
Multi-Handler Configuration
from dc_logger import create_console_file_config
config = create_console_file_config(
file_path="logs/app.log",
level=LogLevel.INFO,
pretty_print=True
)
logger = DCLogger(config, "my_app")
Documentation
| Document | Description |
|---|---|
| USAGE.md | Comprehensive usage guide |
| API_REFERENCE.md | Complete API documentation |
| docs/getting-started.md | Step-by-step introduction |
| docs/configuration.md | Configuration options |
| docs/best-practices.md | Recommended patterns |
| examples/ | Working example scripts |
For AI Agents
See .ai/context.md for a quick reference guide optimized for AI agents.
Key Components
| Component | Import | Description |
|---|---|---|
DCLogger |
from dc_logger import DCLogger |
Main logger class |
ConsoleLogConfig |
from dc_logger import ConsoleLogConfig |
Console configuration |
LogLevel |
from dc_logger import LogLevel |
Log levels (DEBUG, INFO, etc.) |
LogEntity |
from dc_logger import LogEntity |
Entity context for logs |
HTTPDetails |
from dc_logger import HTTPDetails |
HTTP request details |
log_call |
from dc_logger import log_call |
Function logging decorator |
get_logger |
from dc_logger import get_logger |
Get global logger |
correlation_manager |
from dc_logger import correlation_manager |
Distributed tracing |
Log Levels
LogLevel.DEBUG # Detailed debugging information
LogLevel.INFO # General informational messages
LogLevel.WARNING # Warning messages for potential issues
LogLevel.ERROR # Error messages for failures
LogLevel.CRITICAL # Critical errors requiring immediate attention
Cloud Integrations
Datadog
from dc_logger import create_console_datadog_config
config = create_console_datadog_config(
datadog_api_key="your-api-key",
datadog_service="my-service",
datadog_env="production"
)
LangSmith
from dc_logger import create_console_langsmith_config
config = create_console_langsmith_config(
api_key="your-langsmith-api-key",
project_name="observability",
tags=["dc_logger", "staging"]
)
logger = DCLogger(config, "my_app")
Architecture
See documentation/architecture.md for design details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Author
Jae Wilson (@jaewilson07)
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
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 dc_logger-1.2.1.tar.gz.
File metadata
- Download URL: dc_logger-1.2.1.tar.gz
- Upload date:
- Size: 56.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
90507c8e38ca691514447062520aaa3a84493e577be55a2e74e45eee86f0e075
|
|
| MD5 |
d59141b4815a8dfef5940197a6af2c52
|
|
| BLAKE2b-256 |
db6d8e58e00abf2e8407af6e32c4121309c74750b121a4b40c06eb7b747be676
|
File details
Details for the file dc_logger-1.2.1-py3-none-any.whl.
File metadata
- Download URL: dc_logger-1.2.1-py3-none-any.whl
- Upload date:
- Size: 65.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bcf513200be940963050a0bd1ad38ba76eb9f986447956d3f2a274c46e9c0c9c
|
|
| MD5 |
0f70c44370faaa7b6af76f5f1b9dacfd
|
|
| BLAKE2b-256 |
02e143aaf34843c47935d553c9b68334d08c85bdb2cc1eba48c24e53dfd563b3
|