Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the events logger for warning or error levels #4744

Merged
merged 2 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions phones/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from .iq_utils import send_iq_sms

logger = logging.getLogger("eventsinfo")
events_logger = logging.getLogger("events")


MAX_MINUTES_TO_VERIFY_REAL_PHONE = 5
Expand Down Expand Up @@ -296,7 +297,7 @@ def save(self, *args, **kwargs):
if settings.TWILIO_MESSAGING_SERVICE_SID:
register_with_messaging_service(client, twilio_incoming_number.sid)
else:
logger.warning(
events_logger.warning(
"Skipping Twilio Messaging Service registration, since"
" TWILIO_MESSAGING_SERVICE_SID is empty.",
extra={"number_sid": twilio_incoming_number.sid},
Expand Down Expand Up @@ -354,16 +355,16 @@ def register_with_messaging_service(client: Client, number_sid: str) -> None:
if err.status == 409 and err.code == 21710:
# Log "Phone Number is already in the Messaging Service"
# https://www.twilio.com/docs/api/errors/21710
logger.warning("twilio_messaging_service", extra=log_extra)
events_logger.warning("twilio_messaging_service", extra=log_extra)
return
elif err.status == 412 and err.code == 21714:
# Log "Number Pool size limit reached", continue to next service
# https://www.twilio.com/docs/api/errors/21714
closed_sids.append(service_sid)
logger.warning("twilio_messaging_service", extra=log_extra)
events_logger.warning("twilio_messaging_service", extra=log_extra)
else:
# Log and re-raise other Twilio errors
logger.error("twilio_messaging_service", extra=log_extra)
events_logger.error("twilio_messaging_service", extra=log_extra)
raise
else:
return # Successfully registered with service
Expand Down
2 changes: 1 addition & 1 deletion privaterelay/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ def set_index_cache_control_headers(
},
"events": {
"handlers": ["console_err"],
"level": "ERROR",
"level": "WARNING",
"propagate": IN_PYTEST,
},
"eventsinfo": {
Expand Down