Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #103769 > unrolled thread

Re: common mistakes in this simple program

Started byIan Kelly <ian.g.kelly@gmail.com>
First post2016-02-29 16:39 -0700
Last post2016-02-29 16:39 -0700
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: common mistakes in this simple program Ian Kelly <ian.g.kelly@gmail.com> - 2016-02-29 16:39 -0700

#103769 — Re: common mistakes in this simple program

FromIan Kelly <ian.g.kelly@gmail.com>
Date2016-02-29 16:39 -0700
SubjectRe: common mistakes in this simple program
Message-ID<mailman.50.1456789219.20602.python-list@python.org>
On Mon, Feb 29, 2016 at 4:14 PM, Cameron Simpson <cs@zip.com.au> 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.

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web