Example #1
0
 def write(self, *args, **kwargs):
     stream = io.StringIO()
     if kwargs.get('file', sys.stdout) == sys.stdout:
         kwargs['file'] = stream
     print(*args, **kwargs)  # Print into custom stream.
     message = stream.getvalue()
     block = blocks.Message([message])
     self._blocks[self._get_current_line()].append(block)
     self._logger.info(message.rstrip('\n'))
Example #2
0
 def add_text(self, *args, **kwargs):
     show = kwargs.pop('show', False)
     stream = io.StringIO()
     kwargs['file'] = stream
     print(*args, **kwargs)  # Print into custom stream.
     message = stream.getvalue()
     block = blocks.Message([message])
     self._pending.append(block)
     # Remove up to one line break since the logger adds one.
     if message.endswith('\n'):
         message = message[:-1]
     self._logger.info(message)