Skip to main content

hexastack-logging

hexastack-logging

Structured logging, security sanitization, and adapter integrations (Loguru, Rich, Structlog) for Hexastack.

PyPI: hexastack-logging Python 3.13+ Coverage Part of Hexastack Governed by Hexaqual License: Apache 2.0

Part of the Hexastack Framework · Governed by Hexaqual.


1. Overview & Capabilities

hexastack-logging provides high-performance, structured telemetry across the entire Hexastack lifecycle:

  • Multiple Backend Adapters: Native implementations for Loguru, Rich, Structlog, SentryErrorAdapter (Sentry SDK integration), and standard library structured logging.
  • Security & PII Sanitization: Automatic masking of sensitive fields (passwords, tokens, authorization headers, credit cards).
  • Formatters: JSON formatting for cloud aggregators (Datadog, CloudWatch) and colored console formatting for local development.
  • Context & Correlation Integration: Injects active correlation_id from async context into all log outputs.
  • Log Filtering & Levels: Fine-grained level filtering and module-based log routing.

2. Package Anatomy & Key Components

hexastack_logging/
├── domain/          # LogRecord, LogLevel, Logging exceptions
├── ports/           # LoggerPort, FormatterPort, FilterPort, SanitizerPort
├── adapters/        # LoguruAdapter, RichAdapter, StructlogAdapter, StructuredLogger, SentryErrorAdapter
└── infra/           # LoggingBootstrapper (order=10), Formatters, Sanitizers, Config

Key Exports

Category Exports
Adapters StructuredLogger, LoguruAdapter, RichAdapter, StructlogAdapter, SentryErrorAdapter
Bootstrap LoggingBootstrapper (order=10), HexastackLoggingConfig
Formatters JsonFormatter, ConsoleFormatter
Sanitization SanitizerFilter, mask_sensitive_data

3. Monorepo & Sibling Relationships

graph TD
    subgraph SiblingConsumers ["Consumers of LoggerPort"]
        CQRS["hexastack-cqrs (LoggingMiddleware)"]
        FASTAPI["hexastack-fastapi (HttpLoggingMiddleware)"]
        GRPC["hexastack-grpc (LoggingServerInterceptor)"]
        GRAPHQL["hexastack-graphql (CorrelationExtension)"]
        CORE_CTX["hexastack-core (get_correlation_id)"]
    end

    subgraph LoggingSubsystem ["hexastack-logging"]
        BOOT["LoggingBootstrapper (order=10)"]
        ADAPTERS["Adapters (Loguru / Rich / Structlog / StdLib)"]
        SAN["PII Sanitizer & JSON Formatter"]
    end

    BOOT --> ADAPTERS
    ADAPTERS --> SAN
    ADAPTERS -. reads context .-> CORE_CTX

    CQRS -. resolves from DI .-> ADAPTERS
    FASTAPI -. resolves from DI .-> ADAPTERS
    GRPC -. resolves from DI .-> ADAPTERS
    GRAPHQL -. resolves from DI .-> ADAPTERS

Explicit Dependencies (Direct)

  • hexastack-core: Abstract LoggerPort, DI container, and async context tracking.

Implied / Behavioral Relationships (DI-Mediated)

  • Dependency Provider: Binds LoggerPort into the DI container at order=10 (before CQRS order=20), ensuring telemetry is available to all subsequent bootstrappers and middlewares.
  • Correlation ID Synchronization: Automatically reads and outputs get_correlation_id() stored in hexastack_core.utils.context.

Optional Integrations (Extras)

  • [loguru]: Enables loguru>=0.7.0.
  • [rich]: Enables rich>=13.0.0 console formatting.
  • [structlog]: Enables structlog>=24.0.0.
  • [all]: Installs all optional logging backends.

4. Installation

# Standalone standard library logging
pip install hexastack-logging

# With Loguru and Rich support
pip install "hexastack-logging[loguru,rich]"

# All logging backends
pip install "hexastack-logging[all]"

# Via umbrella package
pip install hexastack

5. Configuration Reference

[hexastack.logging]
level = "INFO" # "DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"
format = "json" # "json", "console"
backend = "structlog" # "standard", "loguru", "rich", "structlog"
sanitize_keys = ["password", "token", "secret", "authorization", "api_key"]

6. Quickstart Example

from hexastack_core.infra.bootstrap import bootstrap
from hexastack_core.ports.logging import LoggerPort

runtime = bootstrap(
    config_overrides={
        "logging": {
            "level": "DEBUG",
            "format": "console",
        }
    }
)

logger = runtime.container.get(LoggerPort)
logger.info("Application initialized successfully", extra={"user_count": 42})

Metadata

Release files for hexastack-logging 0.10.0

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

Source distribution (sdist)

Source distribution for hexastack-logging 0.10.0
File Size Uploaded Provenance Actions
hexastack_logging-0.10.0.tar.gz 14.6 kB Without provenance Details for hexastack_logging-0.10.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for hexastack-logging 0.10.0
File Interpreter ABI Platform Actions
hexastack_logging-0.10.0-py3-none-any.whl Python 3 none any Details for hexastack_logging-0.10.0-py3-none-any.whl

Total release size: 37.0 kB

Release files / hexastack_logging-0.10.0.tar.gz

Download URL hexastack_logging-0.10.0.tar.gz
Size 14.6 kB
Tags Source
SHA-256 checksum
How to use checksums
be57879cdde66a648e775ab3601c0dbd3d56bbd3aab26dd39d1430016f0e525a
BLAKE2b-256 checksum
How to use checksums
67599b715ff9b494ae5cd17b4a47b17843671469659b7f52ac5bf6b4f812cf3c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / hexastack_logging-0.10.0-py3-none-any.whl

Download URL hexastack_logging-0.10.0-py3-none-any.whl
Size 22.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b1bb08ee501c6e69a33f3802e8356f2a0f943a879820a063d33f183286377c05
BLAKE2b-256 checksum
How to use checksums
b6f395a4ebd5f85470b9bc0554279645bd7744e470a41ba85602ee47ea81643c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Security for hexastack-logging 0.10.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.

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