Skip to content

Commit

Permalink
Automatically add loggers for plugins in `emsarray.cli.utils.set_verb…
Browse files Browse the repository at this point in the history
…osity`
  • Loading branch information
mx-moth committed May 1, 2023
1 parent 79bee46 commit 45dd065
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/emsarray/cli/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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},
Expand Down

0 comments on commit 45dd065

Please sign in to comment.