Skip to content

Commit

Permalink
Update util.py
Browse files Browse the repository at this point in the history
  • Loading branch information
coreywillwhat authored Apr 28, 2024
1 parent f52de85 commit d4347ba
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions custom_components/audiconnect/util.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from functools import reduce
from datetime import datetime, timezone
from .const import REDACT_LOGS
import logging

_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -55,3 +56,16 @@ def parse_datetime(time_value):
except ValueError:
continue
return None

def log_account_email(email):
if "@" not in email:
return email
if REDACT_LOGS:
local_part, domain = email.split("@")
if len(local_part) > 2:
redacted_local = local_part[0] + "*" * (len(local_part) - 2) + local_part[-1]
else:
redacted_local = local_part[0] + "*" * (len(local_part) - 1)
return redacted_local + "@" + domain
else:
return email

0 comments on commit d4347ba

Please sign in to comment.