mirror of https://github.com/tLDP/python-tldp
add logging logic to driver.py
This commit is contained in:
parent
5f11427f38
commit
fe520cd583
|
@ -11,6 +11,8 @@ from argparse import Namespace
|
||||||
import tldp
|
import tldp
|
||||||
from tldp.utils import arg_isloglevel
|
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__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
@ -116,15 +118,15 @@ def run():
|
||||||
if '--loglevel' in sys.argv:
|
if '--loglevel' in sys.argv:
|
||||||
levelarg = 1 + sys.argv.index('--loglevel')
|
levelarg = 1 + sys.argv.index('--loglevel')
|
||||||
level = arg_isloglevel(sys.argv[levelarg])
|
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
|
# -- produce a configuration from CLI, ENV and CFG
|
||||||
#
|
#
|
||||||
tag = os.path.basename(sys.argv[0]).strip('.py')
|
tag = 'ldptool'
|
||||||
argv = sys.argv[1:]
|
argv = sys.argv[1:]
|
||||||
config, args = tldp.config.collectconfiguration(tag, argv)
|
config, args = tldp.config.collectconfiguration(tag, argv)
|
||||||
|
|
||||||
|
|
||||||
# -- check to see if the user wishes to --list things
|
# -- check to see if the user wishes to --list things
|
||||||
# this function and friends is called 'detail', because
|
# this function and friends is called 'detail', because
|
||||||
# Python reserves a special (fundamental) meaning for the word
|
# Python reserves a special (fundamental) meaning for the word
|
||||||
|
|
Loading…
Reference in New Issue