def log(self, logger):
if self.status_code == 500:
# something actually went wrong; investigate
dct = self.to_dict()
if current_app.debug or current_app.testing:
message = dct.pop("message")
logger.warning(message, extra=dct, exc_info=True)
else:
logger.warning(dct)
else:
# usually log at INFO; a raised exception can be an error or expected behavior (e.g. 404)
logger.info(self.to_dict())
评论列表
文章目录