Closed spaude11 closed 7 months ago
Description: The goal of this issue was to research and insert the error logging function for our website. I researched and found that we can use library logging to create and log the function into our code. I worked on creating some exception log for datamanagement page and feedback page.
Expexcted Outcome: Every error that the website will encounter, we will log into the registry in dropbox for later debugging.
Solution: Work with logging library as well as dropbox to log the error and put it in the registry.
Future Task: Insert more exceptions in code prone to errors.
Description: Adding time to the error logging for clear understanding when did the error happened.
Steps to Reproduce Whenever error happens in the code, it generate a history of error into a file. The file is then sent to dropbox for later review. I wanted to add time into the error log to show when does the error happens
Expected Vs Actual Behaviour The error log was not showing the time behaviour. I changed upload_error_log method in DropBoxLogger class. The error logging is working as expected now.
Code Snippets
def upload_error_log(self, error_log):
# Format the current time
current_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
# Download the existing error log file from Dropbox
try:
_, existing_file = self.dbx.files_download('/Apps/Feedbackfiles/error_log.txt')
existing_error_log = existing_file.content.decode('utf-8')
except dropbox.exceptions.ApiError:
existing_error_log = ""
# Append the new error log with timestamp to the existing content
updated_error_log = existing_error_log + f"\n{current_time} - {error_log}"
# Upload the updated error log back to Dropbox
with open('updated_error_log.txt', 'w') as f:
f.write(updated_error_log)
with open('updated_error_log.txt', 'rb') as f:
try:
self.dbx.files_upload(f.read(), '/Apps/Feedbackfiles/error_log.txt',
mode=dropbox.files.WriteMode.overwrite)
print("Error log updated and uploaded successfully to Dropbox.")
except dropbox.exceptions.ApiError as e:
print(f"Error updating error log on Dropbox: {e}")
Environment Details Pycharm, Streamlit, DropBox
Issue Resolution Added library date time and created method to add the date time into the errors
Description: Recently we found out that Streamlit Sharing has built in error logging. We planned on doing this ourselves but we would like to research this and see if it is suitable for error detection. This will be useful for finding bugs in our website when users are testing our website and giving feedback.
Expected Outcome: Find out whether we should use streamlit sharing built in error logging and if so, figure out how to deploy and use it with our website.