summaryrefslogtreecommitdiff
path: root/buildscripts/resmokelib/logging
diff options
context:
space:
mode:
authorMax Hirschhorn <max.hirschhorn@mongodb.com>2018-01-10 14:15:35 -0500
committerMax Hirschhorn <max.hirschhorn@mongodb.com>2018-01-10 14:15:35 -0500
commit2c451638c2456a3ebc6de87a3d2fcfecbb8d92e3 (patch)
treeb30ebee00d3d3f3080c111146226f593c9b86d0f /buildscripts/resmokelib/logging
parent2cfb8cc89584b9f30f61e51d533ccc789379a9a2 (diff)
downloadmongo-2c451638c2456a3ebc6de87a3d2fcfecbb8d92e3.tar.gz
SERVER-32474 Fix double logging when using --log=buildlogger.
Exposes an additional logger that uses the test's root logger as the parent for any TestCase instances constructor by the hook. The fixture logger still continues to be the parent of the hook logger. Also changes the CleanEveryN hook to explicitly get marked as a failure if a ServerFailure exception is thrown, rather than relying on TestReport.combine() to do so implicitly.
Diffstat (limited to 'buildscripts/resmokelib/logging')
-rw-r--r--buildscripts/resmokelib/logging/loggers.py18
1 files changed, 16 insertions, 2 deletions
diff --git a/buildscripts/resmokelib/logging/loggers.py b/buildscripts/resmokelib/logging/loggers.py
index b7dfaed5f92..bc26174081b 100644
--- a/buildscripts/resmokelib/logging/loggers.py
+++ b/buildscripts/resmokelib/logging/loggers.py
@@ -149,9 +149,9 @@ class ExecutorRootLogger(RootLogger):
"""Create a new TestQueueLogger that will be a child of the "tests" root logger."""
return TestQueueLogger(test_kind, self.tests_root_logger)
- def new_hook_logger(self, behavior_class, job_num, fixture_logger):
+ def new_hook_logger(self, behavior_class, fixture_logger):
"""Create a new child hook logger."""
- return BaseLogger("%s:job%d" % (behavior_class, job_num), parent=fixture_logger)
+ return HookLogger(behavior_class, fixture_logger, self.tests_root_logger)
class JobLogger(BaseLogger):
@@ -314,6 +314,20 @@ class TestQueueLogger(BaseLogger):
BaseLogger.__init__(self, test_kind, parent=tests_root_logger)
+class HookLogger(BaseLogger):
+ def __init__(self, behavior_class, fixture_logger, tests_root_logger):
+ """Initialize a HookLogger.
+
+ :param behavior_class: the hook's name (e.g. CheckReplDBHash, ValidateCollections, etc.).
+ :param fixture_logger: the logger for the fixtures logs.
+ :param tests_root_logger: the root logger for the tests logs.
+ """
+ logger_name = "{}:job{:d}".format(behavior_class, fixture_logger.job_num)
+ BaseLogger.__init__(self, logger_name, parent=fixture_logger)
+
+ self.test_case_logger = BaseLogger(logger_name, parent=tests_root_logger)
+
+
# Util methods
def _fallback_buildlogger_handler(include_logger_name=True):