apache: expose aug_save errors in the debug log (#9169)

Fixes #9168.

* apache: expose aug_save errors in the debug log

* logger arguments wrong way around

* log formatting

Co-authored-by: Brad Warren <bmw@users.noreply.github.com>
This commit is contained in:
alexzorin
2022-01-24 09:33:11 -08:00
committed by GitHub
co-authored by Brad Warren
parent fb564cddd9
commit 7198f43008
2 changed files with 29 additions and 7 deletions
@@ -199,7 +199,13 @@ class ApacheParser:
"""
self.configurator.save_notes = ""
self.aug.save()
ex_errs = self.aug.match("/augeas//error")
try:
self.aug.save()
except IOError:
self._log_save_errors(ex_errs)
raise
# Force reload if files were modified
# This is needed to recalculate augeas directive span
@@ -215,12 +221,15 @@ class ApacheParser:
"""
# Check for the root of save problems
new_errs = self.aug.match("/augeas//error")
# logger.error("During Save - %s", mod_conf)
logger.error("Unable to save files: %s. Attempted Save Notes: %s",
", ".join(err[13:len(err) - 6] for err in new_errs
# Only new errors caused by recent save
if err not in ex_errs), self.configurator.save_notes)
new_errs = [e for e in self.aug.match("/augeas//error") if e not in ex_errs]
for err in new_errs:
logger.debug(
"Error %s saving %s: %s", self.aug.get(err), err[13:len(err) - 6],
self.aug.get(f"{err}/message"))
logger.error(
"Unable to save files: %s.%s", ", ".join(err[13:len(err) - 6] for err in new_errs),
f" Save Notes: {self.configurator.save_notes}" if self.configurator.save_notes else "")
def add_include(self, main_config: str, inc_path: str) -> None:
"""Add Include for a new configuration file if one does not exist