You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

formatters.py 330B

12345678910111213
  1. from logging import Formatter
  2. import re
  3. class PciFormatter(Formatter):
  4. """
  5. Strip card numbers out of log messages to avoid leaving sensitive
  6. information in the logs.
  7. """
  8. def format(self, record):
  9. s = Formatter.format(self, record)
  10. return re.sub(r'\d[ \d-]{15,22}', 'XXXX-XXXX-XXXX-XXXX', s)