From 2eb725dd8d5d039a1c5f40ca0784f638ff989c6b Mon Sep 17 00:00:00 2001 From: Alexander Richards Date: Wed, 17 Apr 2019 14:49:38 +0100 Subject: [PATCH] Improve the debug formatting of startup logging messages. This patch uses pformat to nicely print the various startup dicts for ease of reading. modified: scripts/dirac-daemon.py modified: scripts/monitoring-daemon.py modified: scripts/userdb-update.py modified: scripts/webapp-daemon.py --- scripts/dirac-daemon.py | 9 +++++---- scripts/monitoring-daemon.py | 9 +++++---- scripts/userdb-update.py | 7 ++++--- scripts/webapp-daemon.py | 9 +++++---- 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/scripts/dirac-daemon.py b/scripts/dirac-daemon.py index 82635fb..e5c0837 100755 --- a/scripts/dirac-daemon.py +++ b/scripts/dirac-daemon.py @@ -9,6 +9,7 @@ import logging from logging.handlers import TimedRotatingFileHandler from itertools import chain +from pprint import pformat import pkg_resources import psutil import mock @@ -201,11 +202,11 @@ def start(args): # setup the main app logger logger = logging.getLogger(app_name) - logger.debug("Script called with args: %s", cli_args) + logger.debug("Script called with args:\n%s", pformat(cli_args)) if config_path is None: logger.warning("Config file '%s' does not exist", cli_args['config']) - logger.debug("Active config looks like: %s", config_instance.config) - logger.debug("Runtime args: %s", args) + logger.debug("Active config looks like:\n%s", pformat(config_instance.config)) + logger.debug("Runtime args:\n%s", pformat(vars(args))) # Entry Point Setup ########################################################################### @@ -218,7 +219,7 @@ def start(args): for group, map in entry_point_map.iteritems(): map.update(pkg_resources.get_entry_map(args.extension, group)) config_instance.entry_point_map = entry_point_map - logger.debug("Starting with entry point map: %s", entry_point_map) + logger.debug("Starting with entry point map:\n%s", pformat(entry_point_map)) # Enact the subcommand ########################################################################### diff --git a/scripts/monitoring-daemon.py b/scripts/monitoring-daemon.py index 83e2edc..f2be434 100755 --- a/scripts/monitoring-daemon.py +++ b/scripts/monitoring-daemon.py @@ -13,6 +13,7 @@ import logging from logging.handlers import TimedRotatingFileHandler from itertools import chain +from pprint import pformat import pkg_resources import psutil @@ -201,11 +202,11 @@ def start(args): # setup the main app logger logger = logging.getLogger(app_name) - logger.debug("Script called with args: %s", cli_args) + logger.debug("Script called with args:\n%s", pformat(cli_args)) if config_path is None: logger.warning("Config file '%s' does not exist", cli_args['config']) - logger.debug("Active config looks like: %s", config_instance.config) - logger.debug("Runtime args: %s", args) + logger.debug("Active config looks like:\n%s", pformat(config_instance.config)) + logger.debug("Runtime args:\n%s", pformat(vars(args))) # Entry Point Setup ########################################################################### @@ -218,7 +219,7 @@ def start(args): for group, map in entry_point_map.iteritems(): map.update(pkg_resources.get_entry_map(args.extension, group)) config_instance.entry_point_map = entry_point_map - logger.debug("Starting with entry point map: %s", entry_point_map) + logger.debug("Starting with entry point map:\n%s", pformat(entry_point_map)) # Enact the subcommand ########################################################################### diff --git a/scripts/userdb-update.py b/scripts/userdb-update.py index af8da64..89f62fd 100755 --- a/scripts/userdb-update.py +++ b/scripts/userdb-update.py @@ -5,6 +5,7 @@ import logging import argparse import importlib +from pprint import pformat import pkg_resources from sqlalchemy.exc import SQLAlchemyError @@ -68,11 +69,11 @@ # setup the main app logger logger = logging.getLogger(app_name) - logger.debug("Script called with args: %s", cli_args) + logger.debug("Script called with args:\n%s", pformat(cli_args)) if config_path is None: logger.warning("Config file '%s' does not exist", cli_args['config']) - logger.debug("Active config looks like: %s", config_instance.config) - logger.debug("Runtime args: %s", args) + logger.debug("Active config looks like:\n%s", pformat(config_instance.config)) + logger.debug("Runtime args:\n%s", pformat(vars(args))) # Entry Point Setup ########################################################################### diff --git a/scripts/webapp-daemon.py b/scripts/webapp-daemon.py index 6ec9bc5..1453c1c 100755 --- a/scripts/webapp-daemon.py +++ b/scripts/webapp-daemon.py @@ -8,6 +8,7 @@ import logging from logging.handlers import TimedRotatingFileHandler from itertools import chain +from pprint import pformat import mock import pkg_resources import psutil @@ -210,11 +211,11 @@ def start(args): # setup the main app logger logger = logging.getLogger(app_name) - logger.debug("Script called with args: %s", cli_args) + logger.debug("Script called with args:\n%s", pformat(cli_args)) if config_path is None: logger.warning("Config file '%s' does not exist", cli_args['config']) - logger.debug("Active config looks like: %s", config_instance.config) - logger.debug("Runtime args: %s", args) + logger.debug("Active config looks like:\n%s", pformat(config_instance.config)) + logger.debug("Runtime args:\n%s", pformat(vars(args))) # Entry Point Setup ########################################################################### @@ -227,7 +228,7 @@ def start(args): for group, map in entry_point_map.iteritems(): map.update(pkg_resources.get_entry_map(args.extension, group)) config_instance.entry_point_map = entry_point_map - logger.debug("Starting with entry point map: %s", entry_point_map) + logger.debug("Starting with entry point map:\n%s", pformat(entry_point_map)) # Enact the subcommand ###########################################################################