Last active
August 29, 2015 13:57
-
-
Save russell/9754120 to your computer and use it in GitHub Desktop.
A starting point for python scripts.
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
#!/usr/bin/python | |
import logging | |
log = logging.getLogger(__file__) | |
def main(): | |
"""An example of how the logging works.""" | |
log.debug("Test message") | |
if '__main__' == __name__: | |
import argparse | |
parser = argparse.ArgumentParser( | |
formatter_class=argparse.ArgumentDefaultsHelpFormatter) | |
parser.add_argument( | |
'-v', '--verbose', action='count', default=0, | |
help="Increase verbosity (specify multiple times for more)") | |
args = parser.parse_args() | |
log_level = logging.WARNING | |
if args.verbose == 1: | |
log_level = logging.INFO | |
elif args.verbose >= 2: | |
log_level = logging.DEBUG | |
logging.basicConfig( | |
level=log_level, | |
format='%(asctime)s %(name)s %(levelname)s %(message)s') | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment