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

master
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
1 changed files with 6 additions and 2 deletions

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