From: Cédric Ollivier Date: Wed, 26 Apr 2017 13:31:19 +0000 (+0200) Subject: Logger must be a singleton X-Git-Tag: 0.2~692 X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=commitdiff_plain;h=0acb8eb018afd993c363c05da8a45091abc59fd9;p=functest-xtesting.git Logger must be a singleton It avoids creating a python object for every message printed. Change-Id: Ia42b59db9f7ce4eadc7e91da4d193db646b54d85 Signed-off-by: Cédric Ollivier --- diff --git a/functest/utils/functest_logger.py b/functest/utils/functest_logger.py index 555e9c28..ba52829f 100644 --- a/functest/utils/functest_logger.py +++ b/functest/utils/functest_logger.py @@ -41,6 +41,13 @@ ignore = ["paramiko", class Logger(object): + instance = None + + def __new__(cls, logger_name): + if cls.instance is None: + cls.instance = object.__new__(cls) + return cls.instance + def __init__(self, logger_name): self.setup_logging() self.logger = logging.getLogger(logger_name)