evite erreur dans log au lancement hors context requete

This commit is contained in:
Emmanuel Viennet 2021-10-07 23:33:24 +02:00
parent 085ef05e01
commit 3e45762382
2 changed files with 10 additions and 3 deletions

View File

@ -101,7 +101,10 @@ class LogRequestFormatter(logging.Formatter):
record.url = None record.url = None
record.remote_addr = None record.remote_addr = None
record.sco_user = current_user record.sco_user = current_user
record.sco_admin_mail = current_app.config["SCODOC_ADMIN_MAIL"] if has_request_context():
record.sco_admin_mail = current_app.config["SCODOC_ADMIN_MAIL"]
else:
record.sco_admin_mail = "(pas de requête)"
return super().format(record) return super().format(record)
@ -129,7 +132,11 @@ class LogExceptionFormatter(logging.Formatter):
record.http_method = None record.http_method = None
record.http_params = None record.http_params = None
record.sco_user = current_user record.sco_user = current_user
record.sco_admin_mail = current_app.config["SCODOC_ADMIN_MAIL"]
if has_request_context():
record.sco_admin_mail = current_app.config["SCODOC_ADMIN_MAIL"]
else:
record.sco_admin_mail = "(pas de requête)"
return super().format(record) return super().format(record)

View File

@ -1,7 +1,7 @@
# -*- mode: python -*- # -*- mode: python -*-
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
SCOVERSION = "9.0.48" SCOVERSION = "9.0.49"
SCONAME = "ScoDoc" SCONAME = "ScoDoc"