Log exceptions when calling events
This commit is contained in:
parent
01a5032e87
commit
07a63926c6
2 changed files with 14 additions and 16 deletions
|
@ -137,10 +137,8 @@ class EventHook(object):
|
|||
returns.append(hook.call(event))
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
# TODO don't make this an event call. can lead to error cycles!
|
||||
#self.bot.events.on("log").on("error").call(
|
||||
# message="Failed to call event callback",
|
||||
# data=traceback.format_exc())
|
||||
self.bot.log.error("failed to call event \"%s", [
|
||||
event_path], exc_info=True)
|
||||
called += 1
|
||||
|
||||
end = time.monotonic()
|
||||
|
|
|
@ -33,15 +33,15 @@ class Log(object):
|
|||
file_handler.setFormatter(formatter)
|
||||
self.logger.addHandler(file_handler)
|
||||
|
||||
def debug(self, message, params):
|
||||
self._log(message, params, logging.DEBUG)
|
||||
def info(self, message, params):
|
||||
self._log(message, params, logging.INFO)
|
||||
def warn(self, message, params):
|
||||
self._log(message, params, logging.WARN)
|
||||
def error(self, message, params):
|
||||
self._log(message, params, logging.ERROR)
|
||||
def critical(self, message, params):
|
||||
self._log(message, params, logging.CRITICAL)
|
||||
def _log(self, message, params, level):
|
||||
self.logger.log(level, message, *params)
|
||||
def debug(self, message, params, **kwargs):
|
||||
self._log(message, params, logging.DEBUG, kwargs)
|
||||
def info(self, message, params, **kwargs):
|
||||
self._log(message, params, logging.INFO, kwargs)
|
||||
def warn(self, message, params, **kwargs):
|
||||
self._log(message, params, logging.WARN, kwargs)
|
||||
def error(self, message, params, **kwargs):
|
||||
self._log(message, params, logging.ERROR, kwargs)
|
||||
def critical(self, message, params, **kwargs):
|
||||
self._log(message, params, logging.CRITICAL, kwargs)
|
||||
def _log(self, message, params, level, kwargs):
|
||||
self.logger.log(level, message, *params, **kwargs)
|
||||
|
|
Loading…
Reference in a new issue