Mercurial > public > m209
changeset 32:70673126c158
Replace --verbose with --log option.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Fri, 21 Jun 2013 16:33:06 -0500 |
parents | 853542100fc6 |
children | c9cc6f9f3bad |
files | m209/main.py |
diffstat | 1 files changed, 5 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/m209/main.py Fri Jun 21 15:57:30 2013 -0500 +++ b/m209/main.py Fri Jun 21 16:33:06 2013 -0500 @@ -16,6 +16,7 @@ DESC = "M-209 simulator and utility program" DEFAULT_KEY_LIST = 'm209keys.cfg' +LOG_CHOICES = ['debug', 'info', 'warning', 'error', 'critical'] def encrypt(args): @@ -42,8 +43,8 @@ # create the top-level parser parser = argparse.ArgumentParser(description=DESC) - parser.add_argument('-v', '--verbose', action='store_true', - help='enable verbose output') + parser.add_argument('-l', '--log', choices=LOG_CHOICES, default='warning', + help='set log level [default: %(default)s]') subparsers = parser.add_subparsers(title='list of commands', description='type %(prog)s {command} -h for help on {command}') @@ -83,8 +84,8 @@ args = parser.parse_args(args=argv) - level = logging.DEBUG if args.verbose else logging.WARNING - logging.basicConfig(level=level, format='%(levelname)s:%(message)s') + log_level = getattr(logging, args.log.upper()) + logging.basicConfig(level=log_level, format='%(levelname)s:%(message)s') args.subcommand(args)