add logging logic to driver.py

This commit is contained in:
Martin A. Brown 2016-02-27 10:52:35 -08:00
parent 5f11427f38
commit fe520cd583
1 changed files with 5 additions and 3 deletions

View File

@ -11,6 +11,8 @@ from argparse import Namespace
import tldp
from tldp.utils import arg_isloglevel
logformat = '%(levelname)-9s %(name)s %(filename)s#%(lineno)s %(funcName)s %(message)s'
logging.basicConfig(stream=sys.stderr, format=logformat, level=logging.ERROR)
logger = logging.getLogger(__name__)
@ -116,15 +118,15 @@ def run():
if '--loglevel' in sys.argv:
levelarg = 1 + sys.argv.index('--loglevel')
level = arg_isloglevel(sys.argv[levelarg])
logger.setLevel(level)
# -- set the root logger's level
logging.getLogger().setLevel(level)
# -- produce a configuration from CLI, ENV and CFG
#
tag = os.path.basename(sys.argv[0]).strip('.py')
tag = 'ldptool'
argv = sys.argv[1:]
config, args = tldp.config.collectconfiguration(tag, argv)
# -- check to see if the user wishes to --list things
# this function and friends is called 'detail', because
# Python reserves a special (fundamental) meaning for the word