From 56a611235bc343c8a3386ee4ee019cb20400a7b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Brunner?= Date: Mon, 25 Nov 2024 10:20:50 +0100 Subject: [PATCH] f --- .../gunicorn_app/c2cwsgiutils_app/services.py | 1 + .../waitress_app/c2cwsgiutils_app/services.py | 1 + c2cwsgiutils/loader.py | 20 +++---------------- 3 files changed, 5 insertions(+), 17 deletions(-) diff --git a/acceptance_tests/gunicorn_app/c2cwsgiutils_app/services.py b/acceptance_tests/gunicorn_app/c2cwsgiutils_app/services.py index 084ec31f7..d9461ce9d 100644 --- a/acceptance_tests/gunicorn_app/c2cwsgiutils_app/services.py +++ b/acceptance_tests/gunicorn_app/c2cwsgiutils_app/services.py @@ -2,6 +2,7 @@ import prometheus_client import requests +import sqlalchemy.sql.expression from pyramid.httpexceptions import ( HTTPBadRequest, HTTPForbidden, diff --git a/acceptance_tests/waitress_app/c2cwsgiutils_app/services.py b/acceptance_tests/waitress_app/c2cwsgiutils_app/services.py index 084ec31f7..d9461ce9d 100644 --- a/acceptance_tests/waitress_app/c2cwsgiutils_app/services.py +++ b/acceptance_tests/waitress_app/c2cwsgiutils_app/services.py @@ -2,6 +2,7 @@ import prometheus_client import requests +import sqlalchemy.sql.expression from pyramid.httpexceptions import ( HTTPBadRequest, HTTPForbidden, diff --git a/c2cwsgiutils/loader.py b/c2cwsgiutils/loader.py index 9d84b5577..69317f8e3 100644 --- a/c2cwsgiutils/loader.py +++ b/c2cwsgiutils/loader.py @@ -1,11 +1,9 @@ -import logging -import tempfile -from logging.config import fileConfig +import logging.config from typing import Optional, cast from plaster_pastedeploy import Loader as BaseLoader -from c2cwsgiutils import get_config_defaults +from c2cwsgiutils import get_config_defaults, get_logconfig_dict _LOG = logging.getLogger(__name__) @@ -36,18 +34,6 @@ def setup_logging(self, defaults: Optional[dict[str, str]] = None) -> None: """ if "loggers" in self.get_sections(): - parser = self._get_parser(defaults) - - handlers = [k.strip() for k in parser["handlers"]["keys"].split(",")] - for hh in handlers: - block = parser[f"handler_{hh}"] - if "kwargs" in block: - block["kwargs"] = block["kwargs"].replace("'ext://sys.stdout'", "sys.stdout") - - defaults = self._get_defaults(defaults) - with tempfile.NamedTemporaryFile("w+t", encoding="utf-8") as temp_file: - parser.write(temp_file) - temp_file.flush() - fileConfig(temp_file.name, defaults, disable_existing_loggers=False) + logging.config.dictConfig(get_logconfig_dict(self.filename)) else: logging.basicConfig()