On Mon, Feb 29, 2016 at 4:14 PM, Cameron Simpson <[email protected]> wrote:
> Another remark here: if you're going to log, log the exception as well:
>
> logging.error("something went wrong: %s", e)
>
> Ian's example code is nice and simple to illustrate "log and then reraise"
> but few things are as annoying as log files reciting "something went wrong"
> or the equivalent without any accompanying context information.
The proper way to pass in the exception is as a keyword argument:
logging.error("something went wrong", exc_info=e)
But I actually meant to use logging.exception, which handles this automatically.
--
https://mail.python.org/mailman/listinfo/python-list