2016-03-03

python3 debug CLI option

import argparse
import logging

parser = argparse.ArgumentParser()
parser.add_argument('-d', '--debug', action='store_true', help='debug mode')
args = parser.parse_args()

logging.basicConfig(
    format='%(levelname)s:%(message)s',
    level=(args.debug and logging.DEBUG or logging.WARNING))
logging.debug('Debug mode active.')
# logging.info('')
# logging.warning('')
# logging.error('')
# logging.critical('')