diff --git a/app/__init__.py b/app/__init__.py index 25ea4f6b30..972cff62e7 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -1,6 +1,7 @@ # -*- coding: UTF-8 -* # pylint: disable=invalid-name +import datetime import os import socket import sys @@ -53,7 +54,14 @@ def handle_sco_value_error(exc): def internal_server_error(e): """Bugs scodoc, erreurs 500""" # note that we set the 500 status explicitly - return render_template("error_500.html", SCOVERSION=sco_version.SCOVERSION), 500 + return ( + render_template( + "error_500.html", + SCOVERSION=sco_version.SCOVERSION, + date=datetime.datetime.now().isoformat(), + ), + 500, + ) def handle_invalid_usage(error): @@ -93,6 +101,7 @@ class LogRequestFormatter(logging.Formatter): record.url = None record.remote_addr = None record.sco_user = current_user + record.sco_admin_mail = current_app.config["SCODOC_ADMIN_MAIL"] return super().format(record) @@ -120,7 +129,7 @@ class LogExceptionFormatter(logging.Formatter): record.http_method = None record.http_params = None record.sco_user = current_user - + record.sco_admin_mail = current_app.config["SCODOC_ADMIN_MAIL"] return super().format(record) @@ -197,12 +206,14 @@ def create_app(config_class=DevConfig): "[%(asctime)s] %(sco_user)s@%(remote_addr)s requested %(url)s\n" "%(levelname)s: %(message)s" ) + # les champs additionnels sont définis dans LogRequestFormatter scodoc_exc_formatter = LogExceptionFormatter( "[%(asctime)s] %(sco_user)s@%(remote_addr)s requested %(url)s\n" "%(levelname)s: %(message)s\n" "Referrer: %(http_referrer)s\n" "Method: %(http_method)s\n" "Params: %(http_params)s\n" + "Admin mail: %(sco_admin_mail)s\n" ) if not app.testing: if not app.debug: diff --git a/app/templates/error_500.html b/app/templates/error_500.html index 2396337622..d986a00da5 100644 --- a/app/templates/error_500.html +++ b/app/templates/error_500.html @@ -4,8 +4,9 @@ {% block title %}Une erreur est survenue !{% endblock %} {% block body %}
Oops... ScoDoc version {{SCOVERSION}} a +
Oups... ScoDoc version {{SCOVERSION}} a un problème, désolé.
+{{date}}
Si le problème persiste, contacter l'administrateur de votre site, ou écrire la liste "notes" notes@listes.univ-paris13.fr en