From 45dd06579b782ed5bdf4a1c8330d90f8e936bdc9 Mon Sep 17 00:00:00 2001 From: Tim Heap Date: Mon, 1 May 2023 12:34:25 +1000 Subject: [PATCH] Automatically add loggers for plugins in `emsarray.cli.utils.set_verbosity` --- src/emsarray/cli/utils.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/emsarray/cli/utils.py b/src/emsarray/cli/utils.py index fb3b300..161e7c9 100644 --- a/src/emsarray/cli/utils.py +++ b/src/emsarray/cli/utils.py @@ -16,6 +16,7 @@ from shapely.geometry import box, shape from shapely.geometry.base import BaseGeometry +from emsarray.conventions._registry import entry_point_conventions from .exceptions import CommandException cli_logger = logging.getLogger('emsarray.cli') @@ -210,6 +211,13 @@ def set_verbosity(level: int) -> None: elif level >= 3: level_str = 'DEBUG' + # Include logging handlers for all plugins + entry_point_convention_modules = sorted({ + convention.__module__ + for convention in entry_point_conventions() + if not convention.__module__.startswith('emsarray.') + }) + logging.captureWarnings(True) logging.config.dictConfig({ 'version': 1, @@ -239,6 +247,10 @@ def set_verbosity(level: int) -> None: 'emsarray.cli.errors': { 'handlers': ['error'], 'level': level_str, 'propagate': False }, + **{ + module: {'handlers': ['console'], 'level': level_str} + for module in entry_point_convention_modules + }, 'py.warnings': {'handlers': ['console'], 'level': 'WARNING'}, '__main__': {'handlers': ['console'], 'level': level_str}, 'shapely': {'handlers': [], 'level': 60},