fix: replace log by message for yes/no prompt (#606)

This commit is contained in:
Robert Kaussow 2023-11-23 10:33:36 +01:00 committed by GitHub
parent dfa10dd209
commit 0db500b0a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 4 deletions

View File

@ -85,10 +85,12 @@ class Generator:
and not self.config.config["dry_run"]
):
files_to_overwite_string = "\n".join(files_to_overwite)
self.logger.warning(f"This files will be overwritten:\n{files_to_overwite_string}")
prompt = f"These files will be overwritten:\n{files_to_overwite_string}".replace(
"\n", "\n... "
)
try:
if not FileUtils.query_yes_no("Do you want to continue?"):
if not FileUtils.query_yes_no(f"{prompt}\nDo you want to continue?"):
self.log.sysexit_with_message("Aborted...")
except ansibledoctor.exception.InputError as e:
self.logger.debug(str(e))

View File

@ -129,7 +129,7 @@ class MultilineFormatter(logging.Formatter):
"""Reset color after newline characters."""
def format(self, record): # noqa
record.msg = record.msg.replace("\n", f"\n{colorama.Style.RESET_ALL}... ")
record.msg = record.msg.strip().replace("\n", f"\n{colorama.Style.RESET_ALL}... ")
return logging.Formatter.format(self, record)
@ -236,7 +236,7 @@ class Log:
handler.addFilter(LogFilter(logging.DEBUG))
handler.setFormatter(
MultilineFormatter(
self.critical(
self.debug(
CONSOLE_FORMAT.format(
colorama.Fore.BLUE, colorama.Style.BRIGHT, colorama.Style.RESET_ALL
)