mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-05-04 16:11:11 -04:00
add debug for user issue
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import logging
|
||||
import logging.handlers
|
||||
import re
|
||||
import sys
|
||||
from itertools import product
|
||||
|
||||
@@ -131,3 +132,15 @@ class JSONFormatter(BaseJSONFormatter):
|
||||
except (KeyError, IndexError) as e:
|
||||
logger.exception("failed to format log message: {} not found".format(e))
|
||||
return log_record
|
||||
|
||||
|
||||
def scrub(msg):
|
||||
# Eventually we want to scrub all messages in all logs for phone numbers
|
||||
# and email addresses, masking them. Ultimately this will probably get
|
||||
# refactored into a 'SafeLogger' subclass or something, but let's start here
|
||||
# with phones.
|
||||
phones = re.findall("(?:\\+ *)?\\d[\\d\\- ]{7,}\\d", msg)
|
||||
phones = [phone.replace("-", "").replace(" ", "") for phone in phones]
|
||||
for phone in phones:
|
||||
msg = msg.replace(phone, f"1XXXXX{phone[-5:]}")
|
||||
return msg
|
||||
|
||||
Reference in New Issue
Block a user