Why this matters
Avoids overhead in hot paths when debug logs are disabled.
Guard expensive debug log formatting behind level checks or lazy formatting.
Avoids overhead in hot paths when debug logs are disabled.
Side-by-side examples engineers can pattern-match during review.
logger.debug('state: %s', json.dumps(state))if logger.isEnabledFor(logging.DEBUG):
logger.debug('state: %s', json.dumps(state))logger.debug(f'big {expensive()}')if logger.isEnabledFor(logging.DEBUG): logger.debug('x')From the same buckets as this rule.
Never emit Primary Account Number (PAN) or Sensitive Authentication Data (SAD: CVV/CVC, full track data, PIN) to application or audit logs. Per PCI DSS 4.0 Req. 3 and 10, always mask PAN as first6last4 and fully redact SAD before logging.