diff --git a/bedboss/__init__.py b/bedboss/__init__.py index 76f35b5..4c2de54 100644 --- a/bedboss/__init__.py +++ b/bedboss/__init__.py @@ -1,10 +1,7 @@ """Package-level data""" -import logging from importlib.metadata import version -import coloredlogs - __version__ = version(__package__) __package_name__ = "bedboss" @@ -23,51 +20,3 @@ "__package_name__", "__author__", ] - -_LOGGER = logging.getLogger("bedboss") -_LOGGER.propagate = False -coloredlogs.install( - logger=_LOGGER, - datefmt="%H:%M:%S", - fmt="[%(levelname)s] [%(asctime)s] [BEDBOSS] %(message)s", -) - -_LOGGER_PIPESTAT = logging.getLogger("pipestat") -_LOGGER_PIPESTAT.propagate = False -coloredlogs.install( - logger=_LOGGER_PIPESTAT, - datefmt="%H:%M:%S", - fmt="[%(levelname)s] [%(asctime)s] [PIPESTAT] %(message)s", -) - -_LOGGER_GENIML = logging.getLogger("geniml") -_LOGGER_GENIML.propagate = False -coloredlogs.install( - logger=_LOGGER_GENIML, - datefmt="%H:%M:%S", - fmt="[%(levelname)s] [%(asctime)s] [GENIML] %(message)s", -) - -_LOGGER_BBCONF = logging.getLogger("bbconf") -_LOGGER_BBCONF.propagate = False -coloredlogs.install( - logger=_LOGGER_BBCONF, - datefmt="%H:%M:%S", - fmt="[%(levelname)s] [%(asctime)s] [BBCONF] %(message)s", -) - -_LOGGER_PHC = logging.getLogger("pephubclient") -_LOGGER_PHC.propagate = False -coloredlogs.install( - logger=_LOGGER_PHC, - datefmt="%H:%M:%S", - fmt="[%(levelname)s] [%(asctime)s] [PEPHUBCLIENT] %(message)s", -) - -_LOGGER_REF_CONF = logging.getLogger("refgenconf") -_LOGGER_REF_CONF.propagate = False -coloredlogs.install( - logger=_LOGGER_PHC, - datefmt="%H:%M:%S", - fmt="[%(levelname)s] [%(asctime)s] [REFGENCONF] %(message)s", -) diff --git a/bedboss/bbuploader/__init__.py b/bedboss/bbuploader/__init__.py index 30f889a..5600981 100644 --- a/bedboss/bbuploader/__init__.py +++ b/bedboss/bbuploader/__init__.py @@ -1,13 +1 @@ """Package-level data""" - -import coloredlogs -import logmuse - -from bedboss.bbuploader.constants import PKG_NAME - -_LOGGER = logmuse.init_logger(PKG_NAME) -coloredlogs.install( - logger=_LOGGER, - datefmt="%H:%M:%S", - fmt="[%(levelname)s] [%(asctime)s] [BBUPLOADER] %(message)s", -) diff --git a/bedboss/cli.py b/bedboss/cli.py index f3a8c4b..9e057f9 100644 --- a/bedboss/cli.py +++ b/bedboss/cli.py @@ -1,6 +1,7 @@ import os from importlib.metadata import version as _pkg_version +import logmuse import typer __version__ = _pkg_version("bedboss") @@ -900,8 +901,22 @@ def common( version: bool = typer.Option( None, "--version", "-v", callback=version_callback, help="App version" ), + verbosity: int = typer.Option( + None, "--verbosity", help="Set logging level: 1 (CRITICAL) to 5 (DEBUG)" + ), + logdev: bool = typer.Option(False, "--logdev", help="Use developer logging format"), + silent: bool = typer.Option(False, "--silent", help="Silence logging"), ): - pass + # This callback runs before any command, so it is where logging gets + # configured. Don't move this into `__init__.py`. + # + # Configure the root logger so that bedboss and its dependencies (pipestat, + # geniml, bbconf, pephubclient, refgenconf, bbuploader) all log through one + # handler. Each line is tagged with its logger name, so there is no need to + # attach a per-package handler to identify the source. + logmuse.init_logger( + "", make_root=True, verbosity=verbosity, devmode=logdev, silent=silent + ) app.add_typer(app_bbuploader, name="geo") diff --git a/pyproject.toml b/pyproject.toml index bdde93f..fb650b6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,7 +24,7 @@ classifiers = [ "Topic :: Scientific/Engineering :: Bio-Informatics", ] dependencies = [ - "logmuse>=0.2.7", + "logmuse>=0.3.1", "coloredlogs>=15.0.1", "eido>=0.2.5", "peppy>=0.40.7",