diff --git a/server/packages/tavolo-app/src/tavolo/logging_config.py b/server/packages/tavolo-app/src/tavolo/logging_config.py index daabeaa..bcf008c 100644 --- a/server/packages/tavolo-app/src/tavolo/logging_config.py +++ b/server/packages/tavolo-app/src/tavolo/logging_config.py @@ -2,7 +2,9 @@ Configured once at app import time (see :mod:`tavolo.app`). By default a single console handler at DEBUG level is installed, formatting records as -``{asctime} [{levelname}] ({processName}/{threadName}) - {name} - {message}``. +``{asctime} [{levelname}] ({processName}/{threadName}) - {name} - {message}``; +``urllib3.connectionpool`` is capped at INFO so its per-request DEBUG +chatter does not drown the log. Point the ``LOGGING_CONFIG`` environment variable at a YAML file to take over the configuration entirely; the file follows the :data:`logging.config.dictConfig` schema, e.g.:: @@ -55,6 +57,13 @@ DEFAULT_CONFIG = { "level": "DEBUG", "handlers": ["console"], }, + "loggers": { + # Every pooled HTTP request is a DEBUG record; keep the logger's + # INFO+ output, drop the per-connection noise. + "urllib3.connectionpool": { + "level": "INFO", + }, + }, } diff --git a/server/tests/test_logging_config.py b/server/tests/test_logging_config.py index 3e695d9..602cb0a 100644 --- a/server/tests/test_logging_config.py +++ b/server/tests/test_logging_config.py @@ -18,12 +18,15 @@ class LoggingConfigTest(unittest.TestCase): self._root_level = root.level tavolo = logging.getLogger("tavolo") self._tavolo_level = tavolo.level + pool = logging.getLogger("urllib3.connectionpool") + self._pool_level = pool.level def tearDown(self) -> None: root = logging.getLogger() root.handlers = self._root_handlers root.level = self._root_level logging.getLogger("tavolo").level = self._tavolo_level + logging.getLogger("urllib3.connectionpool").level = self._pool_level def test_default_config_when_unset(self) -> None: configure_logging(None) @@ -33,6 +36,12 @@ class LoggingConfigTest(unittest.TestCase): any(isinstance(h, logging.StreamHandler) for h in root.handlers), "default config installs a console stream handler", ) + # The noisy per-request HTTP logger is capped at INFO while the + # root stays at DEBUG. + self.assertEqual( + logging.INFO, + logging.getLogger("urllib3.connectionpool").getEffectiveLevel(), + ) def test_yaml_config_is_applied(self) -> None: with tempfile.TemporaryDirectory() as tmp: