From: Cédric Ollivier Date: Wed, 26 Apr 2017 13:31:19 +0000 (+0200) Subject: Logger must be a singleton X-Git-Tag: danube.3.RC1~8 X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F45%2F34745%2F1;p=functest.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 (cherry picked from commit 0acb8eb018afd993c363c05da8a45091abc59fd9) --- diff --git a/functest/utils/functest_logger.py b/functest/utils/functest_logger.py index 555e9c28c..ba52829f7 100755 --- 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)