diff --git a/devstack/utils.py b/devstack/utils.py index efc0b7fc..5e921010 100644 --- a/devstack/utils.py +++ b/devstack/utils.py @@ -74,13 +74,17 @@ COWS['unhappy'] = r''' ''' -def configure_logging(verbosity_level=1, dry_run=False): +def construct_log_level(verbosity_level, dry_run=False): + log_level = logging.INFO + if verbosity_level >= 3: + log_level = logging.DEBUG + elif verbosity_level == 2 or dry_run: + log_level = logging.AUDIT + return log_level - # Debug by default + +def configure_logging(log_level): root_logger = logging.getLogger().logger - root_logger.setLevel(logging.DEBUG) - - # Set our pretty logger console_logger = logging.StreamHandler(sys.stdout) console_format = '%(levelname)s: @%(name)s : %(message)s' if sh.in_terminal(): @@ -88,13 +92,6 @@ def configure_logging(verbosity_level=1, dry_run=False): else: console_logger.setFormatter(logging.Formatter(console_format)) root_logger.addHandler(console_logger) - - # Adjust logging verbose level based on the command line switch. - log_level = logging.INFO - if verbosity_level >= 3: - log_level = logging.DEBUG - elif verbosity_level == 2 or dry_run: - log_level = logging.AUDIT root_logger.setLevel(log_level) diff --git a/stack b/stack index dad7a1ef..4927e6a5 100755 --- a/stack +++ b/stack @@ -179,10 +179,11 @@ def main(): prog_name = sys.argv[0] # Configure logging - verbosity = args['verbosity'] - utils.configure_logging(verbosity, args['dryrun']) + log_level = utils.construct_log_level(args['verbosity'], args['dryrun']) + utils.configure_logging(log_level) LOG.debug("Command line options %s" % (args)) + LOG.debug("Log level is: %s" % (log_level)) # Will need root to setup openstack if not sh.got_root(): @@ -208,7 +209,7 @@ def main(): except Exception: utils.goodbye(False) traceback = None - if verbosity >= 3: + if log_level <= logging.DEBUG: # See: http://docs.python.org/library/traceback.html traceback = sys.exc_traceback tb.print_exception(sys.exc_type, sys.exc_value, diff --git a/tools/upload-img.py b/tools/upload-img.py index b2c3bd07..485ef996 100644 --- a/tools/upload-img.py +++ b/tools/upload-img.py @@ -31,7 +31,7 @@ if __name__ == "__main__": (options, args) = parser.parse_args() uris = options.uris or list() uri_sep = ",".join(uris) - utils.configure_logging(3) + utils.configure_logging(logging.DEBUG) config = cfg.StackConfigParser() config.add_section('img') config.set('img', 'image_urls', uri_sep)