Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@soodoku
Last active July 16, 2023 17:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save soodoku/34c083cd0cd5a3162f4fea8caefb2a54 to your computer and use it in GitHub Desktop.
Save soodoku/34c083cd0cd5a3162f4fea8caefb2a54 to your computer and use it in GitHub Desktop.
Remote Logging of Errors With User Approval

Log Errors Remotely With User Approval

"The modern software revolution hasn’t caught up with the open-source research software community. Most open-source research software is still distributed as a binary and emits no logs that can be analyzed by the developer."

From: https://gojiberries.io/2023/07/02/hard-problems-about-research-software/

We provide sample code here for how remote logging with user approval can be enabled.

from flask import Flask, request
import uuid
app = Flask(__name__)
@app.route('/error_endpoint', methods=['POST'])
def receive_error_message():
error_message = request.form.get('error_message')
if error_message:
unique_filename = str(uuid.uuid4()) + ".txt"
with open(unique_filename, 'w') as file:
file.write(error_message)
return "Error message received and stored successfully!"
else:
return "Error: No error message received."
if __name__ == '__main__':
app.run(port=5001)
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment