Why this matters
Structured logging supports levels, handlers, correlation IDs, and can be filtered/aggregated in production.
Use the standard logging module (or your app's logger) instead of print() in committed code.
Structured logging supports levels, handlers, correlation IDs, and can be filtered/aggregated in production.
Side-by-side examples engineers can pattern-match during review.
def handle():
print('starting handler')
...
print('done')import logging
logger = logging.getLogger(__name__)
def handle():
logger.info('starting handler', extra={'op': 'handle'})
...
logger.info('done', extra={'op': 'handle'})print('error:', e)logger.exception('operation failed')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.