Last active
April 25, 2020 03:44
-
-
Save perryism/4d22affa163b3807b2e59c84291d545d to your computer and use it in GitHub Desktop.
Log level arparse
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
import argparse | |
import logging | |
import os | |
import sys | |
parser = argparse.ArgumentParser(description='Read a teflon event file') | |
parser.add_argument("--log", choices=["NOTSET", "DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"], default="INFO", | |
help="Log level") | |
args = parser.parse_args() | |
logging.basicConfig(level=getattr(logging, args.log), stream=sys.stdout) | |
logger = logging.getLogger(__name__) | |
logger.debug("This is debug") | |
logger.info("This is info") | |
logger.warning("This is warning") | |
logger.error("This is error") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment