diff options
Diffstat (limited to 'repo_logging.py')
-rw-r--r-- | repo_logging.py | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/repo_logging.py b/repo_logging.py index 7d050555..58625351 100644 --- a/repo_logging.py +++ b/repo_logging.py | |||
@@ -15,12 +15,13 @@ | |||
15 | """Logic for printing user-friendly logs in repo.""" | 15 | """Logic for printing user-friendly logs in repo.""" |
16 | 16 | ||
17 | import logging | 17 | import logging |
18 | from typing import List | ||
19 | 18 | ||
20 | from color import Coloring | 19 | from color import Coloring |
20 | from error import RepoExitError | ||
21 | 21 | ||
22 | 22 | ||
23 | SEPARATOR = "=" * 80 | 23 | SEPARATOR = "=" * 80 |
24 | MAX_PRINT_ERRORS = 5 | ||
24 | 25 | ||
25 | 26 | ||
26 | class _ConfigMock: | 27 | class _ConfigMock: |
@@ -70,8 +71,22 @@ class RepoLogger(logging.Logger): | |||
70 | handler.setFormatter(_LogColoringFormatter(config)) | 71 | handler.setFormatter(_LogColoringFormatter(config)) |
71 | self.addHandler(handler) | 72 | self.addHandler(handler) |
72 | 73 | ||
73 | def log_aggregated_errors(self, errors: List[Exception]): | 74 | def log_aggregated_errors(self, err: RepoExitError): |
74 | """Print all aggregated logs.""" | 75 | """Print all aggregated logs.""" |
75 | super().error(SEPARATOR) | 76 | self.error(SEPARATOR) |
76 | super().error("Repo command failed due to following errors:") | 77 | |
77 | super().error("\n".join(str(e) for e in errors)) | 78 | if not err.aggregate_errors: |
79 | self.error("Repo command failed: %s", type(err).__name__) | ||
80 | return | ||
81 | |||
82 | self.error( | ||
83 | "Repo command failed due to the following `%s` errors:", | ||
84 | type(err).__name__, | ||
85 | ) | ||
86 | self.error( | ||
87 | "\n".join(str(e) for e in err.aggregate_errors[:MAX_PRINT_ERRORS]) | ||
88 | ) | ||
89 | |||
90 | diff = len(err.aggregate_errors) - MAX_PRINT_ERRORS | ||
91 | if diff: | ||
92 | self.error("+%d additional errors...", diff) | ||