提交 66ee87b2 编写于 作者: L Lukáš Doktor

output: Rename argument logger to loggers

The argument logger actually expects multiple loggers in a list. Let's
reflect that to avoid possible confusion.
Signed-off-by: NLukáš Doktor <ldoktor@redhat.com>
上级 c6d6023e
......@@ -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):
......
......@@ -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 """
......
......@@ -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,
......
......@@ -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()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册