[Python-Dev] Using logging in the stdlib and its unit tests

Antoine Pitrou solipsis at pitrou.net
Wed Dec 8 19:15:37 CET 2010

On Wed, 8 Dec 2010 14:54:09 +0000 (UTC)
Vinay Sajip <vinay_sajip at yahoo.co.uk> wrote:
> Antoine Pitrou <solipsis <at> pitrou.net> writes:
> > I'm not talking specifically about exceptions, but about errors in
> > general. If the case wasn't common, I'm not sure why the error() and
> > critical() methods would exist at all.
> > 
> > (of course I'm assuming error() is meant to output error messages. If
> > that's a wrong interpretation then I'm a bit puzzled )
> > 
> Then again, it's not always helpful when *library* code prints out messages to
> stderr. A user of the library might prefer that an error code be returned or an
> exception raised, so they can deal with the condition most appropriately.

Sorry, what are you arguing about and what kind of answer are you
expecting? Obviously error() is preferrable in some cases and other
means of communicating the error are preferrable in other cases. That's
kind of stating the obvious to me.

But since you are the one you wrote the library and added error() in
the first place, why are you trying to convince me that error() is
not useful? Perhaps you should explain how error() is supposed to be
used for if it's not supposed to log errors.

> > I was talking about the user of a library, not its developer (see the
> > snippet quoted above).
> Yes, but see my response to that. A user of a library doesn't need to know the
> specifics of what loggers that library uses, they just need to make a positive
> statement of where they want warning and error messages go, and how they want
> them formatted.

And my point, again, is that they want it to work by default *without*
making such a positive statement. I'm not sure if I'm supposed to
explain this using different words since you're not appearing to get it.

> BTW we haven't discussed this yet - but these enabled-by-default messages, what
> format should they have? (e.g. just message, logger name + message, logger name
> + severity + message etc.) It might sound like a trivial point, but it also
> seems like whatever you pick, some bikeshed discussions would ensue.

I'm sorry but your way of argumenting is really puzzling to me. You are
trying to find counter-arguments against something which you *already*
implemented yourself in logging.error().

If you're interested in having a theoretical argument about what a
beautiful design should be (and if you want to argue about your own
design decisions), I'll leave the discussion here. I'm only interested
in the *practical* matter of logging having an useful behaviour by
default, which apparently you don't really care about. Fair enough,
but this whole thread is quite telling, IMO, about the general
impedance mismatch between the logging design and the expectations of
casual users (which is 99% of them, certainly).



More information about the Python-Dev mailing list