From 0acb8eb018afd993c363c05da8a45091abc59fd9 Mon Sep 17 00:00:00 2001 From: Cédric Ollivier Date: Wed, 26 Apr 2017 15:31:19 +0200 Subject: Logger must be a singleton MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It avoids creating a python object for every message printed. Change-Id: Ia42b59db9f7ce4eadc7e91da4d193db646b54d85 Signed-off-by: Cédric Ollivier --- functest/utils/functest_logger.py | 7 +++++++ 1 file changed, 7 insertions(+) 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) -- cgit 1.2.3-korg