From: Brian Dolbec Date: Sat, 22 Jun 2013 20:20:43 +0000 (-0700) Subject: Add -D, --debug level to cli X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=7cce980577bdb9f88337f52f1e488796964361b4;p=gentoo-keys.git Add -D, --debug level to cli Comment out a parse_argrs logger line, move the debug reassignment to after it's setting. --- diff --git a/gkeyldap/cli.py b/gkeyldap/cli.py index ba0218b..b506f64 100644 --- a/gkeyldap/cli.py +++ b/gkeyldap/cli.py @@ -16,8 +16,8 @@ from gkeys.seed import Seeds from gkeyldap.search import (LdapSearch, UID, gkey2ldap_map, gkey2SEARCH) -# set debug level to max -logger.setLevel(1) +# set debug level to min +logger.setLevel(0) class Main(object): @@ -49,7 +49,7 @@ class Main(object): @param args: list @returns argparse.Namespace object ''' - logger.debug('MAIN: parse_args; args: %s' % args) + #logger.debug('MAIN: parse_args; args: %s' % args) actions = ['ldapsearch', 'updateseeds'] parser = argparse.ArgumentParser( prog='gkeys', @@ -76,6 +76,8 @@ class Main(object): help='The gpg fingerprint to search for') parser.add_argument('-S', '--status', default=False, help='The seedfile path to use') + parser.add_argument('-D', '--debug', default=0, + help='The logging level to use and report with') return parser.parse_args(args) @@ -89,6 +91,9 @@ class Main(object): logger.error("Main: run; invalid args argument passed in") if isinstance(args, list): args = self.parse_args(args) + if args.debug: + logger.setLevel(int(args.debug)) + logger.debug("MAIN: run; Found alternate debug setting: %s" % str(args.debug)) if args.config: logger.debug("Main: run; Found alternate config request: %s" % args.config) diff --git a/gkeys/cli.py b/gkeys/cli.py index 47c8777..743b622 100644 --- a/gkeys/cli.py +++ b/gkeys/cli.py @@ -24,8 +24,8 @@ from gkeys.config import GKeysConfig, GKEY from gkeys.seed import Seeds -# set debug level to max -logger.setLevel(1) +# set debug level to min +logger.setLevel(0) class Main(object): @@ -56,7 +56,7 @@ class Main(object): @param args: list @returns argparse.Namespace object ''' - logger.debug('MAIN: parse_args; args: %s' % args) + #logger.debug('MAIN: parse_args; args: %s' % args) actions = ['listseed', 'addseed', 'removeseed', 'moveseed', 'listkey', 'addkey', 'removekey', 'movekey'] parser = argparse.ArgumentParser( @@ -90,6 +90,8 @@ class Main(object): help='The seeds file to use or update') parser.add_argument('-S', '--seedfile', dest='seedfile', default=None, help='The seedfile path to use') + parser.add_argument('-D', '--debug', default=0, + help='The logging level to use and report with') return parser.parse_args(args) @@ -103,6 +105,9 @@ class Main(object): logger.error("Main: run; invalid args argument passed in") if isinstance(args, list): args = self.parse_args(args) + if args.debug: + logger.setLevel(int(args.debug)) + logger.debug("MAIN: run; Found alternate debug setting: %s" % str(args.debug)) if args.config: logger.debug("Main: run; Found alternate config request: %s" % args.config) self.config.defaults['config'] = args.config