main: Use repo logger
Bug: b/292704435 Change-Id: Ica02e4c00994a2f64083bb36e8f4ee8aa45d76bd Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/386454 Reviewed-by: Jason Chang <jasonnc@google.com> Commit-Queue: Aravind Vasudevan <aravindvasudev@google.com> Tested-by: Aravind Vasudevan <aravindvasudev@google.com>
This commit is contained in:
parent
7a1f1f70f0
commit
b8fd19215f
3 changed files with 104 additions and 107 deletions
|
@ -15,12 +15,13 @@
|
|||
"""Logic for printing user-friendly logs in repo."""
|
||||
|
||||
import logging
|
||||
from typing import List
|
||||
|
||||
from color import Coloring
|
||||
from error import RepoExitError
|
||||
|
||||
|
||||
SEPARATOR = "=" * 80
|
||||
MAX_PRINT_ERRORS = 5
|
||||
|
||||
|
||||
class _ConfigMock:
|
||||
|
@ -70,8 +71,22 @@ class RepoLogger(logging.Logger):
|
|||
handler.setFormatter(_LogColoringFormatter(config))
|
||||
self.addHandler(handler)
|
||||
|
||||
def log_aggregated_errors(self, errors: List[Exception]):
|
||||
def log_aggregated_errors(self, err: RepoExitError):
|
||||
"""Print all aggregated logs."""
|
||||
super().error(SEPARATOR)
|
||||
super().error("Repo command failed due to following errors:")
|
||||
super().error("\n".join(str(e) for e in errors))
|
||||
self.error(SEPARATOR)
|
||||
|
||||
if not err.aggregate_errors:
|
||||
self.error("Repo command failed: %s", type(err).__name__)
|
||||
return
|
||||
|
||||
self.error(
|
||||
"Repo command failed due to the following `%s` errors:",
|
||||
type(err).__name__,
|
||||
)
|
||||
self.error(
|
||||
"\n".join(str(e) for e in err.aggregate_errors[:MAX_PRINT_ERRORS])
|
||||
)
|
||||
|
||||
diff = len(err.aggregate_errors) - MAX_PRINT_ERRORS
|
||||
if diff:
|
||||
self.error("+%d additional errors...", diff)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue