Problem
maskerlogger 1.1.1 provides excellent secret masking for log output via MaskerFormatter/MaskerFormatterJson, but consumers who need to mask arbitrary strings (not log records) have no public API to do so.
AbstractMaskedLogger._mask_secret(self, msg, matches) exists and is fully functional — it applies capture-group-aware masking with configurable redact percentage using a character-position array. However, because it is prefixed with _, it is a private API not intended for external use.
Current workarounds
Consumers must either:
- Call
_mask_secret directly — brittle, breaks on version bumps, violates encapsulation
- Re-implement capture-group-aware masking from scratch — error-prone, duplicates your logic
Proposed solution
Promote _mask_secret to a public method, e.g.:
def mask_matches(self, text: str, matches: list[re.Match]) -> str:
Or if a broader convenience API is preferred:
def mask_text(self, text: str) -> str:
"""Find secrets in *text* and mask them."""
matches = self.regex_matcher.match_regex_to_line(text)
return self._mask_secret(text, matches)
Use case
Applications that collect log entries from multiple sources in a central pipeline, where masking must happen at aggregation time rather than at the individual formatter level.
Impact
Low — the implementation already exists (_mask_secret), it just needs a public name. No behavioral change to existing formatters.
Problem
maskerlogger1.1.1 provides excellent secret masking for log output viaMaskerFormatter/MaskerFormatterJson, but consumers who need to mask arbitrary strings (not log records) have no public API to do so.AbstractMaskedLogger._mask_secret(self, msg, matches)exists and is fully functional — it applies capture-group-aware masking with configurable redact percentage using a character-position array. However, because it is prefixed with_, it is a private API not intended for external use.Current workarounds
Consumers must either:
_mask_secretdirectly — brittle, breaks on version bumps, violates encapsulationProposed solution
Promote
_mask_secretto a public method, e.g.:Or if a broader convenience API is preferred:
Use case
Applications that collect log entries from multiple sources in a central pipeline, where masking must happen at aggregation time rather than at the individual formatter level.
Impact
Low — the implementation already exists (
_mask_secret), it just needs a public name. No behavioral change to existing formatters.