Fix closing logging handlers (#159)

This commit is contained in:
pemontto
2019-04-01 18:07:29 +11:00
committed by Quim Montal
parent 3601ace5e1
commit 383e7f5478

View File

@ -74,7 +74,7 @@ def main():
vw.whisper_vulnerabilities() vw.whisper_vulnerabilities()
# TODO: fix this to NOT be exit 1 unless in error # TODO: fix this to NOT be exit 1 unless in error
close_logging_handlers() close_logging_handlers(logger)
sys.exit(1) sys.exit(1)
else: else:
@ -89,7 +89,7 @@ def main():
vw.whisper_vulnerabilities() vw.whisper_vulnerabilities()
# TODO: fix this to NOT be exit 1 unless in error # TODO: fix this to NOT be exit 1 unless in error
close_logging_handlers() close_logging_handlers(logger)
sys.exit(1) sys.exit(1)
except Exception as e: except Exception as e:
@ -98,12 +98,12 @@ def main():
logger.error('{}'.format(str(e))) logger.error('{}'.format(str(e)))
print('ERROR: {error}'.format(error=e)) print('ERROR: {error}'.format(error=e))
# TODO: fix this to NOT be exit 2 unless in error # TODO: fix this to NOT be exit 2 unless in error
close_logging_handlers() close_logging_handlers(logger)
sys.exit(2) sys.exit(2)
close_logging_handlers() close_logging_handlers(logger)
def close_logging_handlers(): def close_logging_handlers(logger):
for handler in logger.handlers: for handler in logger.handlers:
handler.close() handler.close()
logger.removeFilter(handler) logger.removeFilter(handler)