aboutsummaryrefslogtreecommitdiffstats
path: root/xtesting
diff options
context:
space:
mode:
authorCédric Ollivier <cedric.ollivier@orange.com>2018-04-17 09:48:15 +0200
committerCédric Ollivier <cedric.ollivier@orange.com>2018-04-17 09:50:51 +0200
commit77d4dfa984fbf5ab034f9550148e0353b643f0dd (patch)
tree53016a02325b33bf0ed1deb7444fc5ff00f79e91 /xtesting
parentb33c445127bf9223fefa75e71408a7848b75773b (diff)
Create a static method to configure logger0.41
It helps OPNFV Features to configure their multiple loggers as self.logger is not suitable in case of multiple modules. Change-Id: I5794a3e323d70abfdd85db89a9890488828efd88 Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
Diffstat (limited to 'xtesting')
-rw-r--r--xtesting/core/feature.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/xtesting/core/feature.py b/xtesting/core/feature.py
index 8474b8a4..ed053e09 100644
--- a/xtesting/core/feature.py
+++ b/xtesting/core/feature.py
@@ -40,16 +40,21 @@ class Feature(testcase.TestCase):
"Cannot get module name %s. Using %s as fallback",
kwargs, self.case_name)
self.logger = logging.getLogger(self.case_name)
+ Feature.configure_logger(self.logger, self.result_file)
+
+ @staticmethod
+ def configure_logger(logger, result_file):
+ """Configure the logger to print in result_file."""
handler = logging.StreamHandler()
handler.setLevel(logging.WARN)
- self.logger.addHandler(handler)
- handler = logging.FileHandler(self.result_file)
+ logger.addHandler(handler)
+ handler = logging.FileHandler(result_file)
handler.setLevel(logging.DEBUG)
- self.logger.addHandler(handler)
+ logger.addHandler(handler)
formatter = logging.Formatter(
'%(asctime)s - %(name)s - %(levelname)s - %(message)s')
handler.setFormatter(formatter)
- self.logger.addHandler(handler)
+ logger.addHandler(handler)
def execute(self, **kwargs):
"""Execute the Python method.