Reduce indentation by returning early.
This commit is contained in:
parent
adc99d383e
commit
b561fd24b5
1 changed files with 13 additions and 7 deletions
|
@ -120,13 +120,19 @@ class LogHandler(vlogging.StreamHandler):
|
||||||
'''
|
'''
|
||||||
Send all of the logged contents to notify, then reset the buffer.
|
Send all of the logged contents to notify, then reset the buffer.
|
||||||
'''
|
'''
|
||||||
if self.log_buffer.getvalue():
|
text = self.log_buffer.getvalue()
|
||||||
try:
|
|
||||||
notify(subject=self.subject, body=self.log_buffer.getvalue())
|
if not text:
|
||||||
except Exception as exc:
|
return
|
||||||
traceback.print_exc()
|
|
||||||
else:
|
try:
|
||||||
self.reset_buffer()
|
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()
|
||||||
|
|
||||||
def reset_buffer(self):
|
def reset_buffer(self):
|
||||||
self.log_buffer = io.StringIO()
|
self.log_buffer = io.StringIO()
|
||||||
|
|
Loading…
Reference in a new issue