Only reset the buffer if notify did not raise an exception.

This commit is contained in:
voussoir 2021-05-14 09:53:02 -07:00
parent f6ded0a879
commit c744135b21
No known key found for this signature in database
GPG key ID: 5F7554F8C26DACCB

View file

@ -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()