Commit 72b6e973 by Renzo Lucioni

Log the repr() of response content when CreditCourse publication fails

%r is used to log the repr() of the response content, which may sometimes contain non-ASCII Unicode. %s would call str() on the response content, sometimes resulting in a UnicodeDecodeError. ECOM-2526.
parent e7903107
...@@ -100,8 +100,11 @@ class LMSPublisher(object): ...@@ -100,8 +100,11 @@ class LMSPublisher(object):
if response.status_code in (200, 201): if response.status_code in (200, 201):
logger.info(u'Successfully published CreditCourse for [%s] to LMS.', course_id) logger.info(u'Successfully published CreditCourse for [%s] to LMS.', course_id)
else: else:
# Note that %r is used to log the repr() of the response content, which may sometimes
# contain non-ASCII Unicode. %s would call str() on the response content, sometimes
# resulting in a UnicodeDecodeError.
logger.error( logger.error(
u'Failed to publish CreditCourse for [%s] to LMS. Status was [%d]. Body was [%s].', u'Failed to publish CreditCourse for [%s] to LMS. Status was [%d]. Body was %r.',
course_id, course_id,
response.status_code, response.status_code,
response.content response.content
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment