fix bug where only exception is passed to logger

This commit is contained in:
Kenneth Kehl
2024-06-12 10:20:06 -07:00
parent 096658ab75
commit f6f99b6124

View File

@@ -141,6 +141,10 @@ class PIIFilter(logging.Filter):
# and email addresses, masking them. Ultimately this will probably get
# refactored into a 'SafeLogger' subclass or something, but let's start here
# with phones.
# Sometimes just an exception object is passed in for the message, skip those.
if not isinstance(msg, str):
return msg
phones = re.findall("(?:\\+ *)?\\d[\\d\\- ]{7,}\\d", msg)
phones = [phone.replace("-", "").replace(" ", "") for phone in phones]
for phone in phones: