forked from ScoDoc/ScoDoc
log exc: ajoute erreur (sur la page) et mail admin
This commit is contained in:
parent
52e837dc81
commit
1f688e2cd5
@ -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:
|
||||
|
@ -4,8 +4,9 @@
|
||||
{% block title %}Une erreur est survenue !{% endblock %}
|
||||
{% block body %}
|
||||
<h1>Une erreur est survenue !</h1>
|
||||
<p>Oops... <span style="color:red;"><b>ScoDoc version <span style="font-size: 120%;">{{SCOVERSION}}</span></b></span> a
|
||||
<p>Oups...</tt> <span style="color:red;"><b>ScoDoc version <span style="font-size: 120%;">{{SCOVERSION}}</span></b></span> a
|
||||
un problème, désolé.</p>
|
||||
<p><tt style="font-size:60%">{{date}}</tt></p>
|
||||
|
||||
<p> Si le problème persiste, contacter l'administrateur de votre site,
|
||||
ou écrire la liste "notes" <a href="mailto:notes@listes.univ-paris13.fr">notes@listes.univ-paris13.fr</a> en
|
||||
|
Loading…
Reference in New Issue
Block a user