Skip to main content

DC Logger

Python 3.8+ License: MIT

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)

Release files for dc-logger 1.2.1

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

Source distribution (sdist)

Source distribution for dc-logger 1.2.1
File Size Uploaded
dc_logger-1.2.1.tar.gz 56.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dc-logger 1.2.1
File Interpreter ABI Platform
dc_logger-1.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 121.7 kB

Release files / dc_logger-1.2.1.tar.gz

Download URL dc_logger-1.2.1.tar.gz
Size 56.0 kB
Tags Source
SHA-256 checksum
How to use checksums
90507c8e38ca691514447062520aaa3a84493e577be55a2e74e45eee86f0e075
BLAKE2b-256 checksum
How to use checksums
db6d8e58e00abf2e8407af6e32c4121309c74750b121a4b40c06eb7b747be676
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / dc_logger-1.2.1-py3-none-any.whl

Download URL dc_logger-1.2.1-py3-none-any.whl
Size 65.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bcf513200be940963050a0bd1ad38ba76eb9f986447956d3f2a274c46e9c0c9c
BLAKE2b-256 checksum
How to use checksums
02e143aaf34843c47935d553c9b68334d08c85bdb2cc1eba48c24e53dfd563b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release history Release notifications | RSS feed

This release

1.2.1 This release

2 release files

1.2.0

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.1.0

2 release files

0.0.1

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