From 628a176e8123a0a552919d3034cb903c533e666a Mon Sep 17 00:00:00 2001 From: chase mateusiak Date: Thu, 31 Aug 2023 18:18:57 -0500 Subject: [PATCH 1/2] fixing logging --- src/isocomp/__main__.py | 31 +++++--------------------- src/isocomp/utils/configure_logging.py | 19 +++++++--------- 2 files changed, 14 insertions(+), 36 deletions(-) diff --git a/src/isocomp/__main__.py b/src/isocomp/__main__.py index c05bae6..498a2f0 100644 --- a/src/isocomp/__main__.py +++ b/src/isocomp/__main__.py @@ -12,6 +12,7 @@ # local imports from .Coordinates import create_comparison_windows from .Compare import find_unique_isoforms +from .utils.configure_logging import configure_logging logger = logging.getLogger(__name__) @@ -328,34 +329,14 @@ def main(args=None) -> None: # help message try: log_level = args.log_level.upper() + if log_level not in ['CRITICAL', 'ERROR', 'WARNING', 'INFO', 'DEBUG']: + raise ValueError("The logging level must be one of debug, " + "info, warning, error, " + "or critical.") except AttributeError: sys.exit(arg_parser.print_help()) - # set the logging details - log_config = { - "version": 1, - "root": { - "handlers": ["console"], - "level": f"{log_level}" - }, - "handlers": { - "console": { - "formatter": "std_out", - "class": "logging.StreamHandler" - } - }, - "formatters": { - "std_out": { - "format": "%(asctime)s : %(module)s : " + - "%(funcName)s : line: %(lineno)d\n" + - "\tprocess details : %(process)d, %(processName)s\n" + - "\tthread details : %(thread)d, %(threadName)s\n" + - "\t%(levelname)s : %(message)s", - "datefmt": "%Y-%m-%d %H:%M:%S" - } - } - } - dictConfig(log_config) + configure_logging(log_level) # log the cmd line arguments at the debug level logger.debug(sys.argv) logger.debug(str(args)) diff --git a/src/isocomp/utils/configure_logging.py b/src/isocomp/utils/configure_logging.py index e3142b6..44f1aa5 100644 --- a/src/isocomp/utils/configure_logging.py +++ b/src/isocomp/utils/configure_logging.py @@ -27,18 +27,15 @@ def configure_logging(level=logging.INFO, >>> configure_logging(level=logging.DEBUG) >>> configure_logging(level=logging.INFO) """ - if level not in [logging.DEBUG, - logging.INFO, - logging.WARNING, - logging.ERROR, - logging.CRITICAL]: - raise ValueError("The logging level must be one of logging.DEBUG, " - "logging.INFO, logging.WARNING, logging.ERROR, " - "or logging.CRITICAL.") - + log_level = level.upper() + if log_level not in ['CRITICAL', 'ERROR', 'WARNING', 'INFO', 'DEBUG']: + raise ValueError("The logging level must be one of debug, " + "info, warning, error, " + "or critical.") + if not isinstance(to_file, bool): raise ValueError("to_file must be a boolean.") - + if to_file: if not filename: raise ValueError("filename must be provided when to_file is True.") @@ -69,7 +66,7 @@ def configure_logging(level=logging.INFO, 'handlers': handlers, 'root': { 'handlers': list(handlers.keys()), - 'level': level, + 'level': log_level, }, } From f6080eda2a363f7082f7d8c337eb9b3deccf1769 Mon Sep 17 00:00:00 2001 From: chase mateusiak Date: Thu, 31 Aug 2023 18:19:13 -0500 Subject: [PATCH 2/2] bump to version 0.2.2 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 2ccbc16..6e204f9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "isocomp" -version = "0.2.1" +version = "0.2.2" description = "" authors = ["Yutong Qiu ", "Chia Sin Liew ", "Rupesh Kesharwani ", "Bida Gu ", "chase mateusiak ",