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

Added different level of logs throughout whole codebase. #342

Merged
merged 13 commits into from
Feb 12, 2023

Conversation

Satendra-SR
Copy link
Member

@Satendra-SR Satendra-SR commented Feb 3, 2023

#338

Please complete the following steps and check these boxes before filing your PR:

Types of changes

  • Bug fix (a change which fixes an issue)
  • New feature (a change which adds functionality)

Short description of what this resolves:

Why these change required? What problem does it solve?
By adding different levels of logs to the whole code base, we can get logs to provide detailed information about what is happening in the code, making it easier to debug issues and identify the root cause of problems.
Here we are implementing the following level of logs in the system.

  • INFO
  • WARN
  • ERROR

Checklist:

  • I have performed a self-review of my own code.
  • The code follows the style guidelines of this project.
  • The code changes are passing the CI checks
  • I have documented my code wherever required.
  • The changes requires a change to the documentation.
  • I have updated the documentation based on the my changes.

@Satendra-SR Satendra-SR self-assigned this Feb 3, 2023
Comment on lines 125 to 127
logger.info(
f"Successfully updated {column_name} with value {mapped_table_column_value} for user with id {user_details.id}"
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not required

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

@@ -43,6 +45,7 @@ def get_program_sequence_id(self, jsonData):

if not user_program_details:
# Need to log this
logger.error("No user program details found")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we print user_id as well

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

Comment on lines 28 to 30
logger.info(
f" user_phone: {self.user_phone}, call_log_id: {self.call_log_id}, content_version_id: {self.content_version_id}"
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

Comment on lines 82 to 86
logger.info(
"IVR prompt response exists for prompt '{}' and response '{}'".format(
prompt_name, prompt_response
)
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not nededed

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

return partner_system_phone.partner_id
except Exception as e:
logger.error(
f"Error while fetching partner id by system phone {system_phone}: {e}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
f"Error while fetching partner id by system phone {system_phone}: {e}"
f"Error while fetching partner id by system phone {system_phone}. Error message: {e}"

print("Error: " + str(e))
print(traceback.format_exc())
logger.error(
f"Error occurred while commiting the data in the database. Error Message: {e}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
f"Error occurred while commiting the data in the database. Error Message: {e}"
f"Error occurred while committing the data in the database. Error message: {e}"

split_prompt = data.split("-")
return split_prompt
except Exception as e:
logger.error(f"Error while splitting prompt by hyphen: {e}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
logger.error(f"Error while splitting prompt by hyphen: {e}")
logger.error(f"Error while splitting prompt '{data}' by hyphen. Error message: {e}")

program_sub_prompt = data.split("_")
return program_sub_prompt
except Exception as e:
logger.error(f"Error while splitting prompt by underscore: {e}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
logger.error(f"Error while splitting prompt by underscore: {e}")
logger.error(f"Error while splitting prompt '{data}' by underscore. Error message: {e}")

Comment on lines 43 to 44
except Exception as e:
logger.error(f"Error while getting program prompt id: {e}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This try and except is not needed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

main.py Outdated
return (
jsonify(message="Currently, the system do not accept a GET request"),
405,
)
except Exception as e:
print(e)
logger.error("[ERROR] An unexpected error occurred: %s" % e)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
logger.error("[ERROR] An unexpected error occurred: %s" % e)
logger.error(f"An unexpected error occurred. Error message: {e}" )

main.py Outdated
@@ -63,6 +63,7 @@ def retry_failed_webhook(transaction_log_service):

log.processed = True
db_helper.save(log)
logger.info("[INFO] Successfully processed the failed log")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No needed

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

main.py Outdated
@@ -116,9 +117,12 @@ def handle_payload(jsonData, is_retry_payload=False):
if jsonData.get("flow_category") == "dry_flow" and not is_retry_payload:
handle_contact_fields_and_groups(jsonData)
else:
logger.error("[ERROR] No 'contact' key found in the input JSON data.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
logger.error("[ERROR] No 'contact' key found in the input JSON data.")
logger.error("No 'contact' key found in the input JSON data. {josnData}")

main.py Outdated
return -1
except:
except Exception as e:
logger.error(f"[ERROR] Exception Occured while handeling payload: {e}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
logger.error(f"[ERROR] Exception Occured while handeling payload: {e}")
logger.error(f"Exception occurred while handling payload: {e}")

main.py Outdated
return False
logger.info("[INFO] Payload processing completed successfully.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

@Satendra-SR Satendra-SR merged commit a7ddc95 into develop Feb 12, 2023
@Satendra-SR Satendra-SR deleted the feature/338/add-logs-throughout-whole-codebase branch February 12, 2023 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants