Reduce indentation by returning early.

master
voussoir 2021-09-16 21:17:36 -07:00
parent adc99d383e
commit b561fd24b5
No known key found for this signature in database
GPG Key ID: 5F7554F8C26DACCB
1 changed files with 13 additions and 7 deletions

View File

@ -120,10 +120,16 @@ class LogHandler(vlogging.StreamHandler):
'''
Send all of the logged contents to notify, then reset the buffer.
'''
if self.log_buffer.getvalue():
text = self.log_buffer.getvalue()
if not text:
return
try:
notify(subject=self.subject, body=self.log_buffer.getvalue())
notify(subject=self.subject, body=text)
except Exception as exc:
# Normally I'd put this into log.warning or log.error, but then we
# might get stuck in an infinite loop! Not sure what's best.
traceback.print_exc()
else:
self.reset_buffer()