From c744135b216dbd5e52ebf626706d89738d2e5ca5 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Fri, 14 May 2021 09:53:02 -0700 Subject: [PATCH] Only reset the buffer if notify did not raise an exception. --- voussoirkit/operatornotify.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/voussoirkit/operatornotify.py b/voussoirkit/operatornotify.py index 6b5c918..2d1311f 100644 --- a/voussoirkit/operatornotify.py +++ b/voussoirkit/operatornotify.py @@ -115,8 +115,12 @@ class LogHandler(vlogging.StreamHandler): Send all of the logged contents to notify, then reset the buffer. ''' if self.log_buffer.getvalue(): - notify(subject=self.subject, body=self.log_buffer.getvalue()) - self.reset_buffer() + try: + notify(subject=self.subject, body=self.log_buffer.getvalue()) + except Exception as exc: + traceback.print_exc() + else: + self.reset_buffer() def reset_buffer(self): self.log_buffer = io.StringIO()