Created
January 20, 2015 15:20
-
-
Save kdiverson/299c4f9a9afce40241bd to your computer and use it in GitHub Desktop.
logging with argparse, from https://stackoverflow.com/questions/14097061/easier-way-to-enable-verbose-logging
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
import logging | |
parser = argparse.ArgumentParser() | |
parser.add_argument('-d','--debug', | |
help='Print lots of debugging statements', | |
action="store_const",dest="loglevel",const=logging.DEBUG, | |
default=logging.WARNING | |
) | |
parser.add_argument('-v','--verbose', | |
help='Be verbose', | |
action="store_const",dest="loglevel",const=logging.INFO | |
) | |
args = parser.parse_args() | |
logging.basicConfig(level=args.loglevel) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment