-
Notifications
You must be signed in to change notification settings - Fork 0
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
Added logs while importing course #7
base: master
Are you sure you want to change the base?
Conversation
cms/djangoapps/contentstore/tasks.py
Outdated
@@ -526,9 +526,11 @@ def get_dir_for_filename(directory, filename): | |||
return | |||
|
|||
if not user_has_access(user): | |||
logging.info(f'Course import {course_key_string}: User is not allowed to import') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is required.
cms/djangoapps/contentstore/tasks.py
Outdated
return | ||
|
||
if not file_is_supported(): | ||
logging.info(f'Course import {course_key_string}: File not supported') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is required.
cms/djangoapps/contentstore/tasks.py
Outdated
@@ -737,14 +739,18 @@ def validate_course_olx(courselike_key, course_dir, status): | |||
if not course_import_olx_validation_is_enabled(): | |||
return olx_is_valid | |||
try: | |||
if str(courselike_key) == "course-v1:ArbiX+CS101+2014_T3": | |||
logging.info(log_prefix + "Validating. Calling olxcleaner.validate") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is log_prefix
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the default prefix they are using in every log of this function. This string is equal to f"Course import {courselike_key}"
cms/djangoapps/contentstore/tasks.py
Outdated
if str(courselike_key) == "course-v1:ArbiX+CS101+2014_T3": | ||
logging.info(log_prefix + "Course validated. No errors") | ||
except Exception as e: # pylint: disable=broad-except | ||
LOGGER.exception(f'{log_prefix}: CourseOlx could not be validated' + str(e)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LOGGER.exception
automatically prints the stack trace so I don't think `str(e) is needed here.
common/djangoapps/util/monitoring.py
Outdated
@@ -13,9 +13,11 @@ def monitor_import_failure(course_key, import_step, message=None, exception=None | |||
""" | |||
set_custom_attribute('course_import_failure', import_step) | |||
set_custom_attributes_for_course_key(course_key) | |||
logging.info(f"Course import failed at step {import_step} for course with key {course_key}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't these also be behind the course key condition?
…/xmodule/xmodule/modulestore in files xml.py and xml_importer.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please add a prefix of Investigation Log:
to all the conditional logs we are adding, so other developers have an idea of why these logs have been added!
@@ -743,7 +743,7 @@ def validate_course_olx(courselike_key, course_dir, status): | |||
ignore=settings.COURSE_OLX_VALIDATION_IGNORE_LIST, | |||
allowed_xblocks=ALL_ALLOWED_XBLOCKS | |||
) | |||
except Exception: # pylint: disable=broad-except | |||
except Exception as e: # pylint: disable=broad-except |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why was this changed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added "as e" after Exception to print it. Awais bhai told me LOGGER.Exception prints exception. Restored old code.
if str(target_course_id) == "course-v1:ArbiX+CS101+2014_T3": | ||
logging.info(f"Investigation Log: {target_course_id} : Course Descriptor is None") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this shouldn't be part of the if course_descriptor is None:
block. the logs should be immediately after the finally:
block.
logging.info(f"Investigation Log: {target_course_id} : {course_descriptor} ")
something like this.
@@ -522,6 +525,8 @@ def get_policy(usage_id): | |||
course_descriptor = system.process_xml(etree.tostring(course_data, encoding='unicode')) | |||
# If we fail to load the course, then skip the rest of the loading steps | |||
if isinstance(course_descriptor, ErrorBlock): | |||
if str(target_course_id) == "course-v1:ArbiX+CS101+2014_T3": | |||
logging.info(f"Investigation Log: {target_course_id} : Course Descriptor is instance of ErrorBlock") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see single quotes here in this file, please use single quotes here too.
Added logs near course validation in course import.