Skip to content

Instantly share code, notes, and snippets.

@armancohan
Last active February 13, 2018 17:16
Show Gist options
  • Select an option

  • Save armancohan/1f98028d5518f25b74813e7484919879 to your computer and use it in GitHub Desktop.

Select an option

Save armancohan/1f98028d5518f25b74813e7484919879 to your computer and use it in GitHub Desktop.
Simple verbose logging setup example
from argparse import ArgumentParser
ap = ArgumentParser()
ap.add_argument('--verbose', '-v', action='store_true', default=False)
args = ap.parse_args()
imoprt logging
log = logging.getLogger(__name__)
if args.verbose:
log.basicConfig(format="%(levelname)s: %(message)s", level=log.DEBUG)
log.info("Verbose output.")
else:
log.basicConfig(format="%(levelname)s: %(message)s", level=log.ERROR)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment