Skip to content

Commit

Permalink
Updated logging system: log formatting consistent across cli and direct
Browse files Browse the repository at this point in the history
function calls, cli now includes log info from submodules, formatting
for clarity for warnings printing when progress bar is active.
  • Loading branch information
cflerin committed Sep 18, 2019
1 parent 8320d80 commit f8f3d9a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
8 changes: 8 additions & 0 deletions src/pyscenic/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
4 changes: 0 additions & 4 deletions src/pyscenic/cli/pyscenic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion src/pyscenic/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit f8f3d9a

Please sign in to comment.