Last active
January 10, 2018 15:29
-
-
Save jorisdevrede/cc4057ed84e507b05ece016e0a2dd6a2 to your computer and use it in GitHub Desktop.
python logger
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
#!/usr/bin/env python | |
import argparse | |
import logging | |
def main(): | |
logging.debug('main') | |
if __name__ == '__main__': | |
parser = argparse.ArgumentParser() | |
parser.add_argument('--log', | |
metavar='l', | |
type=str, | |
default='INFO', | |
help="WARNING, INFO, DEBUG. Default is INFO") args = parser.parse_args() | |
logging.basicConfig(level=getattr(logging, args.log.upper(), 'INFO')) | |
main() | |
logging.info('start') | |
logging.error('error') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment