From 66ee87b21d2d39508f605a9a70225f99c21f3d3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Doktor?= Date: Tue, 8 Aug 2017 17:29:41 +0200 Subject: [PATCH] output: Rename argument logger to loggers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The argument logger actually expects multiple loggers in a list. Let's reflect that to avoid possible confusion. Signed-off-by: Lukáš Doktor --- avocado/core/output.py | 18 ++++++++++-------- avocado/core/runner.py | 4 ++-- .../robot/avocado_robot/__init__.py | 4 ++-- .../avocado_runner_remote/__init__.py | 4 ++-- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/avocado/core/output.py b/avocado/core/output.py index cdbcf082..cb64471f 100644 --- a/avocado/core/output.py +++ b/avocado/core/output.py @@ -608,19 +608,21 @@ class LoggingFile(object): """ def __init__(self, prefix='', level=logging.DEBUG, - logger=[logging.getLogger()]): + loggers=None): """ - Constructor. Sets prefixes and which logger is going to be used. + Constructor. Sets prefixes and which loggers are going to be used. :param prefix - The prefix for each line logged by this object. + :param level: Log level to be used when writing messages. + :param loggers: Loggers into which write should be issued. (list) """ self._prefix = prefix + if not loggers: + loggers = [logging.getLogger()] self._level = level self._buffer = [] - if not isinstance(logger, list): - logger = [logger] - self._logger = logger + self._loggers = loggers def write(self, data): """" @@ -651,7 +653,7 @@ class LoggingFile(object): """ Passes lines of output to the logging module. """ - for lg in self._logger: + for lg in self._loggers: lg.log(self._level, self._prefix + line) def _flush_buffer(self): @@ -666,10 +668,10 @@ class LoggingFile(object): return False def add_logger(self, logger): - self._logger.append(logger) + self._loggers.append(logger) def rm_logger(self, logger): - self._logger.remove(logger) + self._loggers.remove(logger) class Throbber(object): diff --git a/avocado/core/runner.py b/avocado/core/runner.py index 643bd7e5..e34fceb9 100644 --- a/avocado/core/runner.py +++ b/avocado/core/runner.py @@ -305,8 +305,8 @@ class TestRunner(object): logging.getLogger('paramiko')] logger_list_stderr = [TEST_LOG, logging.getLogger('paramiko')] - sys.stdout = output.LoggingFile(logger=logger_list_stdout) - sys.stderr = output.LoggingFile(logger=logger_list_stderr) + sys.stdout = output.LoggingFile(loggers=logger_list_stdout) + sys.stderr = output.LoggingFile(loggers=logger_list_stderr) def sigterm_handler(signum, frame): # pylint: disable=W0613 """ Produce traceback on SIGTERM """ diff --git a/optional_plugins/robot/avocado_robot/__init__.py b/optional_plugins/robot/avocado_robot/__init__.py index eefaa2fe..446bc55f 100644 --- a/optional_plugins/robot/avocado_robot/__init__.py +++ b/optional_plugins/robot/avocado_robot/__init__.py @@ -54,8 +54,8 @@ class RobotTest(test.SimpleTest): Create the Robot command and execute it. """ suite_name, test_name = self.name.name.split(':')[1].split('.') - log_stdout = output.LoggingFile(logger=[self.log], level=logging.INFO) - log_stderr = output.LoggingFile(logger=[self.log], level=logging.ERROR) + log_stdout = output.LoggingFile(loggers=[self.log], level=logging.INFO) + log_stderr = output.LoggingFile(loggers=[self.log], level=logging.ERROR) result = run(self.filename, suite=suite_name, test=test_name, diff --git a/optional_plugins/runner_remote/avocado_runner_remote/__init__.py b/optional_plugins/runner_remote/avocado_runner_remote/__init__.py index 9382cf76..eae429b1 100644 --- a/optional_plugins/runner_remote/avocado_runner_remote/__init__.py +++ b/optional_plugins/runner_remote/avocado_runner_remote/__init__.py @@ -487,8 +487,8 @@ class RemoteTestRunner(TestRunner): if self.job.args.show_job_log: logger_list.append(app_logger) output.add_log_handler(paramiko_logger.name) - sys.stdout = output.LoggingFile(logger=logger_list) - sys.stderr = output.LoggingFile(logger=logger_list) + sys.stdout = output.LoggingFile(loggers=logger_list) + sys.stderr = output.LoggingFile(loggers=logger_list) try: try: self.setup() -- GitLab