Sanitization
provide.foundation.logger.processors.sanitization
¶
TODO: Add module docstring.
Functions¶
create_sanitization_processor
¶
create_sanitization_processor(
enabled: bool = True,
mask_patterns: bool = True,
sanitize_dicts: bool = True,
) -> Any
Create a processor that sanitizes sensitive data from logs.
This processor uses Foundation's security utilities to automatically: - Mask secrets based on common patterns (API keys, tokens, passwords) - Sanitize dictionary keys (Authorization, X-API-Key, etc.)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
enabled
|
bool
|
Whether sanitization is enabled |
True
|
mask_patterns
|
bool
|
Whether to apply pattern-based secret masking |
True
|
sanitize_dicts
|
bool
|
Whether to sanitize dictionary values |
True
|
Returns:
| Type | Description |
|---|---|
Any
|
Structlog processor function |
Examples:
>>> log.info("API call", headers={"Authorization": "Bearer secret123"})
# Logs: {"Authorization": "Bearer ***"}