aboutsummaryrefslogtreecommitdiffstats
path: root/configure.py
diff options
context:
space:
mode:
authorSimon Warta <[email protected]>2017-04-09 17:00:50 +0200
committerSimon Warta <[email protected]>2017-04-18 09:36:25 +0200
commitd31a991f5fb0859892261dd0bda018b6fdb99b25 (patch)
tree0e0aa7239cd9de5528d62c03f80444603c3f34db /configure.py
parent47941e603923945bbcc7fc520f049e076bcf7568 (diff)
Extract setup_logging() from main()
Diffstat (limited to 'configure.py')
-rwxr-xr-xconfigure.py29
1 files changed, 17 insertions, 12 deletions
diff --git a/configure.py b/configure.py
index 4f578751c..d4e8e59d8 100755
--- a/configure.py
+++ b/configure.py
@@ -212,6 +212,8 @@ def make_build_doc_commands(build_paths, options):
def process_command_line(args): # pylint: disable=too-many-locals
"""
Handle command line options
+ Do not use logging in this method as command line options need to be
+ available before logging is setup.
"""
parser = optparse.OptionParser(
@@ -2473,6 +2475,20 @@ class BotanConfigureLogHandler(logging.StreamHandler, object):
sys.exit(1)
+def setup_logging(options):
+ if options.verbose:
+ log_level = logging.DEBUG
+ elif options.quiet:
+ log_level = logging.WARNING
+ else:
+ log_level = logging.INFO
+
+ lh = BotanConfigureLogHandler(sys.stdout)
+ lh.setFormatter(logging.Formatter('%(levelname) 7s: %(message)s'))
+ logging.getLogger().addHandler(lh)
+ logging.getLogger().setLevel(log_level)
+
+
def main(argv=None):
"""
Main driver
@@ -2481,20 +2497,9 @@ def main(argv=None):
if argv is None:
argv = sys.argv
- lh = BotanConfigureLogHandler(sys.stdout)
- lh.setFormatter(logging.Formatter('%(levelname) 7s: %(message)s'))
- logging.getLogger().addHandler(lh)
-
options = process_command_line(argv[1:])
- def log_level():
- if options.verbose:
- return logging.DEBUG
- if options.quiet:
- return logging.WARNING
- return logging.INFO
-
- logging.getLogger().setLevel(log_level())
+ setup_logging(options)
logging.info('%s invoked with options "%s"' % (
argv[0], ' '.join(argv[1:])))