Browse Source

backup: show errors at top of email notification

master
Jim Paris 1 year ago
parent
commit
46f9f98860
1 changed files with 18 additions and 11 deletions
  1. +18
    -11
      backup.py

+ 18
- 11
backup.py View File

@@ -470,17 +470,24 @@ def main(argv: typing.List[str]):
if email and not args.dry_run:
backup.log('I', f"sending error notification to {email}")

# Show all of our log output. Use a ":" prefix for
# warnings, errors, and notices so that they get
# highlighted by the mail reader.
body = [ "Logs:" ]
for (letter, msg) in backup.logs:
if letter in "EWN":
prefix = ":"
else:
prefix = " "
body.append(f"{prefix}{letter}: {msg}")
body_text = "\n".join(body).encode()
def write_logs(title, only_include=None):
body = [ title ]
for (letter, msg) in backup.logs:
if only_include and letter not in only_include:
continue
# Use a ":" prefix for warnings/errors/notices so that
# the mail reader highlights them.
if letter in "EWN":
prefix = ":"
else:
prefix = " "
body.append(f"{prefix}{letter}: {msg}")
return "\n".join(body).encode()


body_text = write_logs("Logged errors and warnings:", "EWN")
body_text += "\n"
body_text += write_logs("All logs:")

# Subject summary
if errmsg and warnmsg:


Loading…
Cancel
Save