Skip to content

Commit 04f7fa3

Browse files
committed
chore(index_and_notify): use exc_info and logger_context with logger.error
1 parent 8d99e16 commit 04f7fa3

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

api/management/commands/index_and_notify.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
)
2525
from deployments.models import ERU, Personnel, PersonnelDeployment
2626
from main.sentry import SentryMonitor
27+
from main.utils import logger_context
2728
from notifications.hello import get_hello
2829
from notifications.models import RecordType, Subscription, SubscriptionType, SurgeAlert
2930
from notifications.notification import send_notification
@@ -922,12 +923,10 @@ def index_records(self, records, to_create=True):
922923
def bulk(self, actions):
923924
try:
924925
created, errors = bulk(client=ES_CLIENT, actions=actions)
925-
if len(errors):
926-
logger.error("Produced the following errors:")
927-
logger.error("[%s]" % ", ".join(map(str, errors)))
928-
except Exception as e:
929-
logger.error("Could not index records")
930-
logger.error("%s..." % str(e)[:512])
926+
if errors:
927+
logger.error("(bulk): produced errors:", extra=logger_context(dict(errors=errors)))
928+
except Exception:
929+
logger.error("(bulk): could not index records", exc_info=True)
931930

932931
# Remove items in a queryset where updated_at == created_at.
933932
# This leaves us with only ones that have been modified.

0 commit comments

Comments
 (0)