From 3e4576238223a7ba6b16e748662da8af2a29751d Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Thu, 7 Oct 2021 23:33:24 +0200 Subject: [PATCH] evite erreur dans log au lancement hors context requete --- app/__init__.py | 11 +++++++++-- sco_version.py | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/__init__.py b/app/__init__.py index 972cff62..11d728a3 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -101,7 +101,10 @@ 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"] + 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) @@ -129,7 +132,11 @@ 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"] + + 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) diff --git a/sco_version.py b/sco_version.py index 7f494f75..0c6fdbc8 100644 --- a/sco_version.py +++ b/sco_version.py @@ -1,7 +1,7 @@ # -*- mode: python -*- # -*- coding: utf-8 -*- -SCOVERSION = "9.0.48" +SCOVERSION = "9.0.49" SCONAME = "ScoDoc"