Log exceptions when calling events

This commit is contained in:
jesopo 2018-08-30 14:32:59 +01:00 committed by dongfix
parent 01a5032e87
commit 07a63926c6
2 changed files with 14 additions and 16 deletions

View file

@ -137,10 +137,8 @@ class EventHook(object):
returns.append(hook.call(event)) returns.append(hook.call(event))
except Exception as e: except Exception as e:
traceback.print_exc() traceback.print_exc()
# TODO don't make this an event call. can lead to error cycles! self.bot.log.error("failed to call event \"%s", [
#self.bot.events.on("log").on("error").call( event_path], exc_info=True)
# message="Failed to call event callback",
# data=traceback.format_exc())
called += 1 called += 1
end = time.monotonic() end = time.monotonic()

View file

@ -33,15 +33,15 @@ class Log(object):
file_handler.setFormatter(formatter) file_handler.setFormatter(formatter)
self.logger.addHandler(file_handler) self.logger.addHandler(file_handler)
def debug(self, message, params): def debug(self, message, params, **kwargs):
self._log(message, params, logging.DEBUG) self._log(message, params, logging.DEBUG, kwargs)
def info(self, message, params): def info(self, message, params, **kwargs):
self._log(message, params, logging.INFO) self._log(message, params, logging.INFO, kwargs)
def warn(self, message, params): def warn(self, message, params, **kwargs):
self._log(message, params, logging.WARN) self._log(message, params, logging.WARN, kwargs)
def error(self, message, params): def error(self, message, params, **kwargs):
self._log(message, params, logging.ERROR) self._log(message, params, logging.ERROR, kwargs)
def critical(self, message, params): def critical(self, message, params, **kwargs):
self._log(message, params, logging.CRITICAL) self._log(message, params, logging.CRITICAL, kwargs)
def _log(self, message, params, level): def _log(self, message, params, level, kwargs):
self.logger.log(level, message, *params) self.logger.log(level, message, *params, **kwargs)