重试时Python韧性日志异常

重试时Python韧性日志异常,python,python-tenacity,Python,Python Tenacity,我正在使用坚韧包重试一个函数。我的重试装饰器如下所示: @retry(wait=wait_exponential(multiplier=1/(2**5), max=60), after=after_log(logger, logging.INFO)) INFO:mymodule:Finished call to 'mymodule.MyClass.myfunction' after 0.001(s), this was the 1st time calling it. 在异常情况下,我会收到

我正在使用
坚韧
包重试一个函数。我的重试装饰器如下所示:

@retry(wait=wait_exponential(multiplier=1/(2**5), max=60), after=after_log(logger, logging.INFO))
INFO:mymodule:Finished call to 'mymodule.MyClass.myfunction' after 0.001(s), this was the 1st time calling it.
在异常情况下,我会收到如下日志消息:

@retry(wait=wait_exponential(multiplier=1/(2**5), max=60), after=after_log(logger, logging.INFO))
INFO:mymodule:Finished call to 'mymodule.MyClass.myfunction' after 0.001(s), this was the 1st time calling it.
除了已经记录的异常之外,我还想记录实际的异常(1行格式,最好不是堆栈跟踪)。这能用毅力做到吗?还是我只需要捕获异常、打印并重新引发