Last active
February 13, 2018 17:16
-
-
Save armancohan/1f98028d5518f25b74813e7484919879 to your computer and use it in GitHub Desktop.
Simple verbose logging setup example
This file contains hidden or 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
| 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