Class LoggingRedactionAuditListener

java.lang.Object
com.tnsai.quality.redaction.LoggingRedactionAuditListener
All Implemented Interfaces:
RedactionAuditListener

public final class LoggingRedactionAuditListener extends Object implements RedactionAuditListener
SLF4J-backed RedactionAuditListener — emits one structured log line per audit event (issue #80).

Use this as the zero-config default when wiring AuditingRedactor: operators get a basic compliance audit trail without writing any code, and the line format is shaped for easy parsing by Datadog / Loki / Splunk.


 Redactor audited = new AuditingRedactor(
         PatternRedactor.withDefaults(),
         LoggingRedactionAuditListener.atInfo());
 

Output shape: each event becomes one log line at the configured level (default INFO; CRITICAL severity always escalates to WARN regardless of the configured floor):

 redaction.applied scope=MEMORY_WRITE severity=CRITICAL total=2
   patterns=credit_card:1,email:1 tenant=acme session=s-42 trace=ab12cd
 

What's omitted on purpose: the redacted content itself, the placeholder strings, and the offset spans. The audit log is a counter / metadata log — never a leak vector. Operators who need the placeholders for grep-then-vault correlation should write a custom listener that pulls from RedactionAuditEvent.eventId().

Thread-safety: SLF4J Logger is thread-safe; this class is stateless beyond the immutable level config.

Since:
0.9.0 (issue #80)
  • Constructor Details

    • LoggingRedactionAuditListener

      public LoggingRedactionAuditListener(LoggingRedactionAuditListener.Level floor)
      Parameters:
      floor - minimum log level for non-critical events; CRITICAL severity always escalates to WARN regardless
  • Method Details

    • atInfo

      public static LoggingRedactionAuditListener atInfo()
      Convenience: log at INFO floor (CRITICAL still escalates to WARN).
    • atDebug

      public static LoggingRedactionAuditListener atDebug()
      Convenience: log at DEBUG floor for noisy environments.
    • onRedaction

      public void onRedaction(RedactionAuditEvent event)
      Description copied from interface: RedactionAuditListener
      Called once per scrub that produced at least one finding. Implementations should not throw — the AuditingRedactor decorator catches anything to keep audit failures from breaking the redaction hot path, but a clean implementation never relies on that safety net.
      Specified by:
      onRedaction in interface RedactionAuditListener
      Parameters:
      event - aggregated audit info; never null