diff --git a/avocado/core/output.py b/avocado/core/output.py index cdbcf0825a972d384bbca251eac587b1a0d61aad..cb64471fbed2b043361e5ffc2c55a48f2527b663 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 643bd7e5115792a33da5b6a3b1896d6d4935dd31..e34fceb99b013e2a7d9af49b27b078a573bd4cde 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 eefaa2feae2b65daa4f971ac49de98a51651d5cc..446bc55f42e9c8c1bbcbc0ca9844af460dd10dfe 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 9382cf7637e6d7186edeaa0987224cab71505b18..eae429b194d291c37a2a914da9cf1aa301d11b95 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()