Log unhandled exceptions properly
This commit is contained in:
parent
91c8526c88
commit
9fd30b8853
1 changed files with 10 additions and 5 deletions
15
zeronet.py
15
zeronet.py
|
@ -45,11 +45,16 @@ def main():
|
|||
handler.close()
|
||||
logger.removeHandler(handler)
|
||||
|
||||
|
||||
except (Exception, ): # Prevent closing
|
||||
except Exception, err: # Prevent closing
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
traceback.print_exc(file=open("log/error.log", "a"))
|
||||
try:
|
||||
import logging
|
||||
logging.exception("Unhandled exception: %s" % err)
|
||||
except Exception, log_err:
|
||||
print "Failed to log error:", log_err
|
||||
traceback.print_exc()
|
||||
from Config import config
|
||||
traceback.print_exc(file=open(config.log_dir + "/error.log", "a"))
|
||||
|
||||
if main and main.update_after_shutdown: # Updater
|
||||
# Restart
|
||||
|
@ -65,4 +70,4 @@ def main():
|
|||
print "Bye."
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
main()
|
||||
|
|
Loading…
Reference in a new issue