diff --git a/avocado/core/output.py b/avocado/core/output.py index bd9d219bd154ad39dba655f7017834b7f4270e34..07b2fb5e36b58f8cddcc12ef76dbfe60f1cfd946 100644 --- a/avocado/core/output.py +++ b/avocado/core/output.py @@ -242,10 +242,27 @@ class OutputManager(object): term_support.MOVE_BACK + THROBBER_STEPS[2], term_support.MOVE_BACK + THROBBER_STEPS[3]] - def __init__(self, logger_name='avocado.app'): - self.console_log = logging.getLogger('avocado.app') + def __init__(self, console_logger='avocado.app', list_mode=False): + self.list_mode = list_mode + self.console_log = logging.getLogger(console_logger) + self.paginator = get_paginator() self.throbber_pos = 0 + def log(self, msg, level=logging.INFO, skip_newline=False): + """ + Write a message to the avocado.app logger or the paginator. + + :param msg: Message to write + :type msg: string + """ + extra = {'skip_newline': skip_newline} + if self.list_mode: + if not skip_newline: + msg += '\n' + self.paginator.write(msg) + else: + self.console_log.log(level=level, msg=msg, extra=extra) + def throbber_progress(self, progress_from_test=False): """ Give an interactive indicator of the test progress @@ -267,16 +284,6 @@ class OutputManager(object): else: self.throbber_pos += 1 - def _log(self, msg, level=logging.INFO, skip_newline=False): - """ - Write a message to the avocado.app logger. - - :param msg: Message to write - :type msg: string - """ - extra = {'skip_newline': skip_newline} - self.console_log.log(level=level, msg=msg, extra=extra) - def start_file_logging(self, logfile, loglevel, unique_id): """ Start the main file logging. @@ -319,7 +326,7 @@ class OutputManager(object): :param msg: Message to write. """ - self._log(msg, level=logging.INFO, skip_newline=skip_newline) + self.log(msg, level=logging.INFO, skip_newline=skip_newline) def error(self, msg): """ @@ -327,7 +334,7 @@ class OutputManager(object): :param msg: Message to write. """ - self._log(msg, level=logging.ERROR) + self.log(msg, level=logging.ERROR) def log_healthy(self, msg, skip_newline=False): """