From c59f022a55a10e7e0bf9ec971124d31b77fb921a Mon Sep 17 00:00:00 2001 From: Einar Forselv Date: Thu, 5 Dec 2019 10:15:49 +0100 Subject: [PATCH] Properly log exceptions --- restic_compose_backup/alerts/__init__.py | 1 + restic_compose_backup/alerts/smtp.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/restic_compose_backup/alerts/__init__.py b/restic_compose_backup/alerts/__init__.py index 4c3c046..6c33513 100644 --- a/restic_compose_backup/alerts/__init__.py +++ b/restic_compose_backup/alerts/__init__.py @@ -24,6 +24,7 @@ def send(subject: str = None, body: str = None, alert_type: str = 'INFO'): ) except Exception as ex: logger.error("Exception raised when sending alert [%s]: %s", instance.name, ex) + logger.exception(ex) if len(alert_classes) == 0: logger.info("No alerts configured") diff --git a/restic_compose_backup/alerts/smtp.py b/restic_compose_backup/alerts/smtp.py index 5bf9a2b..e6bde1f 100644 --- a/restic_compose_backup/alerts/smtp.py +++ b/restic_compose_backup/alerts/smtp.py @@ -51,6 +51,6 @@ class SMTPAlert(BaseAlert): server.sendmail(self.user, self.to, msg.as_string()) logger.info('Email sent') except Exception as ex: - logger.error(ex) + logger.exception(ex) finally: server.close()