diff --git a/src/pyscenic/__init__.py b/src/pyscenic/__init__.py index 74f4e66..9be135e 100644 --- a/src/pyscenic/__init__.py +++ b/src/pyscenic/__init__.py @@ -2,3 +2,11 @@ from ._version import get_versions __version__ = get_versions()['version'] del get_versions + +import logging +from pyscenic.log import create_logging_handler +LOGGER = logging.getLogger(__name__) +# Set logging level. +logging_debug_opt = False +LOGGER.addHandler(create_logging_handler(logging_debug_opt)) +LOGGER.setLevel(logging.DEBUG) diff --git a/src/pyscenic/cli/pyscenic.py b/src/pyscenic/cli/pyscenic.py index 03cebbb..af7e036 100644 --- a/src/pyscenic/cli/pyscenic.py +++ b/src/pyscenic/cli/pyscenic.py @@ -393,10 +393,6 @@ def create_argument_parser(): def main(argv=None): - # Set logging level. - logging_debug_opt = False - LOGGER.addHandler(create_logging_handler(logging_debug_opt)) - LOGGER.setLevel(logging.DEBUG) # Parse arguments. parser = create_argument_parser() diff --git a/src/pyscenic/log.py b/src/pyscenic/log.py index 6cac32b..d36d7ad 100644 --- a/src/pyscenic/log.py +++ b/src/pyscenic/log.py @@ -17,5 +17,5 @@ def create_logging_handler(debug: bool) -> logging.Handler: # to DEBUG, information will still be outputted. In addition, errors and warnings are more # severe than info and therefore will always be outputted to the log. ch.setLevel(logging.DEBUG if debug else logging.INFO) - ch.setFormatter(logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')) + ch.setFormatter(logging.Formatter('\n%(asctime)s - %(name)s - %(levelname)s - %(message)s')) return ch