log.py 753 B

123456789101112131415161718192021222324
  1. from typing import Optional
  2. from ..element import Element
  3. from ..vue import register_component
  4. register_component('log', __file__, 'log.js')
  5. class Log(Element):
  6. def __init__(self, max_lines: Optional[int] = None) -> None:
  7. """Log view
  8. Create a log view that allows to add new lines without re-transmitting the whole history to the client.
  9. :param max_lines: maximum number of lines before dropping oldest ones (default: `None`)
  10. """
  11. super().__init__('log')
  12. self._props['max_lines'] = max_lines
  13. self.classes('border whitespace-pre font-mono')
  14. self.style('opacity: 1 !important; cursor: text !important')
  15. def push(self, line: str) -> None:
  16. self.run_method('push', line)