Skip to content

Commit 8003713

Browse files
committed
feat: show error logs in normal mode
Signed-off-by: Demolus13 <[email protected]>
1 parent 4b25cc0 commit 8003713

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/macaron/console.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ def __init__(self, *args: Any, verbose: bool = False, **kwargs: Any) -> None:
3737
self.setLevel(logging.DEBUG)
3838
self.command = ""
3939
self.logs: list[str] = []
40+
self.error_logs: list[str] = []
4041
self.description_table = Table(show_header=False, box=None)
4142
self.description_table_content: dict[str, str | Status] = {
4243
"Package URL:": Status("[green]Processing[/]"),
@@ -118,6 +119,7 @@ def emit(self, record: logging.LogRecord) -> None:
118119

119120
if record.levelno >= logging.ERROR:
120121
self.logs.append(f"[red][ERROR][/red] {log_time} {msg}")
122+
self.error_logs.append(f"[red][ERROR][/red] {log_time} {msg}")
121123
elif record.levelno >= logging.WARNING:
122124
self.logs.append(f"[yellow][WARNING][/yellow] {log_time} {msg}")
123125
else:
@@ -386,10 +388,17 @@ def make_layout(self) -> Group:
386388
A rich Group object containing the layout for the live console display.
387389
"""
388390
layout: list[RenderableType] = []
391+
if self.error_logs:
392+
error_log_panel = Panel(
393+
"\n".join(self.error_logs),
394+
title="Error Logs",
395+
title_align="left",
396+
border_style="red",
397+
)
398+
layout = layout + [error_log_panel]
389399
if self.command == "analyze":
390-
layout = layout + [Rule(" DESCRIPTION", align="left")]
391400
if self.description_table.row_count > 0:
392-
layout = layout + ["", self.description_table]
401+
layout = layout + [Rule(" DESCRIPTION", align="left"), "", self.description_table]
393402
if self.progress_table.row_count > 0:
394403
layout = layout + ["", self.progress, "", self.progress_table]
395404
if self.failed_checks_table.row_count > 0:

0 commit comments

Comments
 (0)