| 32 | |
| 33 | |
| 34 | class LogsOutput: |
| 35 | def __init__(self, console: ConsolePrintingToBuffer) -> None: |
| 36 | self.console = console |
| 37 | |
| 38 | def __rich_console__( |
| 39 | self, console: Console, options: ConsoleOptions |
| 40 | ) -> RenderResult: |
| 41 | suffix_len = options.max_height - 1 |
| 42 | self.console.forget(options.max_height - 1) |
| 43 | group = Group(*self.console.logs) |
| 44 | panel = Panel(group, title="LOGS", expand=True, box=box.MINIMAL) |
| 45 | |
| 46 | # if the terminal is too narrow, print only suffix of lines |
| 47 | rendered_lines = console.render_lines(panel) |
| 48 | lines = [rendered_lines[0]] + rendered_lines[1:][-suffix_len:] |
| 49 | new_line = Segment.line() |
| 50 | for i, line in enumerate(lines): |
| 51 | yield from line |
| 52 | if i + 1 < len(lines): |
| 53 | yield new_line |
| 54 | |
| 55 | |
| 56 | class MonitoringOutput: |