Registry / devops / csrd-logging

csrd-logging

JSON →
library0.5.28pypypiunverified

Context-enriched logging mixin that adds structured fields like request_id, user_id, and service name to logs. Supports optional auto-instrumentation via OpenTelemetry. Current version 0.5.28, released irregularly on PyPI. Requires Python >= 3.12.

pip install csrd-logging
INSTALL
IMPORT
SIG · CSRD-LOGGING
C
csrd-logging
devopspythonv0.5.28
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

CsrdLoggingMixin
from csrd import CsrdLoggingMixin
from csrd_logging import CsrdLoggingMixin

Basic usage: configure once, then mixin into classes to enrich logs with context fields.

import os from csrd_logging import CsrdLoggingMixin # Must be called before any logging CsrdLoggingMixin.configure( service_name="my-service", environment=os.environ.get("ENV", "development") ) class MyHandler(CsrdLoggingMixin): def handle(self, request_id: str): self.set_context(request_id=request_id) self.logger.info("Processing request") # Example usage handler = MyHandler() handler.handle("req-123")
Debug
Known issues
breakingconfigure() must be called before any logging occurs or before creating any mixin instances. Failure results in missing context or errors.
fix
Call CsrdLoggingMixin.configure() at application startup, ideally before importing any modules that do logging.
affects: >=0.5.0
deprecatedThe method set_context(key=value) is deprecated in favor of the newer context manager style with_log_context(). It still works but may be removed in a future major version.
fix
Use with self.with_log_context(key=value): instead of self.set_context(key=value).
affects: >=0.5.0
gotchaThe library renames the standard logging module's logger; don't import logging directly after calling configure() as it will not include context.
fix
Always use self.logger from the mixin, not logging.getLogger(__name__).
affects: all
brokenThe library does not support Python < 3.12 due to use of new typing syntax. Attempting to install on older Python will fail.
fix
Upgrade to Python 3.12 or higher.
affects: >=0.5.0
Upgrade
Version history
0.5.28latest on PyPI · released May 18, 2026
Audit
Dependencies
opentelemetry-apioptionalOptional, for OpenTelemetry integration.
opentelemetry-sdkoptionalOptional, for OpenTelemetry integration.
Agent activity
15 hits · last 30 days
node
14
Resources
csrd-logging — pip install csrd-logging · libregistry