import es, sys, os.path, time import traceback as tb_module def except_hook(type, value, ttemplateback): error_list = tb_module.format_exception(type, value, ttemplateback) for message in error_list: es.dbgmsg(0, message.strip()) f = open(es.getAddonPath(__name__[__name__.find('.') + 1:].replace('.', '/')) + '/errors.log', 'a') f.writelines([time.strftime('%x %X\n')] + error_list + ['\n']) f.close() sys.excepthook = except_hook