Browse Source

Ensure root logger passes all messages to all handlers

This lets the handlers set their own levels. Otherwise all
handlers are limited to the messages that the root logger
is willing to pass to them (e.g. they only get messages that
pass root logger's level setting)
Hamilton Turner 11 years ago
parent
commit
fd1f83c534
1 changed files with 9 additions and 2 deletions
  1. 9 2
      toolset/run-tests.py

+ 9 - 2
toolset/run-tests.py

@@ -132,11 +132,18 @@ def main(argv=None):
     parser.set_defaults(**defaults) # Must do this after add, or each option's default will override the configuration file default
     args = parser.parse_args(remaining_argv)
 
-    # Set up our initial logging level
+    # Set up logging
+
     numeric_level = getattr(logging, args.log.upper(), logging.ERROR)
     if not isinstance(numeric_level, int):
         raise ValueError('Invalid log level: %s' % loglevel)
-    logging.basicConfig(level=numeric_level)
+    stdout = logging.StreamHandler()
+    stdout.setLevel(numeric_level)
+    stdout.setFormatter(logging.Formatter("%(name)-12s: %(levelname)-8s %(message)s"))
+    rootlogger = logging.getLogger()
+    rootlogger.setLevel(logging.DEBUG)  # Pass all messages to all handlers
+    rootlogger.addHandler(stdout)
+    logging.captureWarnings(True)
 
     # Verify and massage options
     if args.client_user is None: