python_structlog_config.config¶
Core structlog configuration.
Extracted from GridFlow backend/src/infrastructure/logging_config.py Enhanced with OTel and Sentry support per PRD specifications
Functions¶
|
Configure structlog with optional OTel and Sentry integration. |
|
Get a structlog logger instance. |
Module Contents¶
- python_structlog_config.config.configure_structlog(log_level: str = 'INFO', json_output: bool = False, enable_otel: bool = False, enable_sentry: bool = False, sentry_dsn: str | None = None, service_name: str | None = None, environment: str | None = None) None¶
Configure structlog with optional OTel and Sentry integration.
- Args:
log_level: Logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL) json_output: Use JSON renderer instead of console (default: False) enable_otel: Enable OpenTelemetry integration (default: False) enable_sentry: Enable Sentry integration (default: False) sentry_dsn: Sentry DSN (required if enable_sentry=True) service_name: Service name for context (optional) environment: Environment name (dev, staging, prod)
- Example:
>>> configure_structlog( ... log_level="INFO", ... json_output=True, ... service_name="my-api" ... )
- python_structlog_config.config.get_logger(name: str | None = None)¶
Get a structlog logger instance.
- Args:
name: Logger name (optional)
- Returns:
Structlog logger instance
- Example:
>>> logger = get_logger(__name__) >>> logger.info("Application started")