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

Bill Janssen janssen at parc.com
Fri Dec 10 19:16:18 CET 2010

Glenn Linderman <v+python at g.nevcal.com> wrote:

> On 12/10/2010 12:06 AM, Vinay Sajip wrote:
> >> >  This simplistic easy usage somewhat echo's Glenn's comment on this thread
> > about logging seeming way to daunting as presented today.  It needn't be.
> >> >  
> > Indeed, and the very first code sample in the logging documentation shows
> > exactly the simplistic easy usage you're talking about. I can't see why anyone
> > would be scared off by that example.
> It didn't scare me off.  But it wasn't _quite_ comprehensive enough to
> keep me from being put off by the next bit of manual, (about 8%, as
> mentioned before), which had lots of discussion, but no more examples,
> so what is lacking up front is a few more examples of using the
> convenience methods as Greg apparently does, without configuration,
> but showing use in multiple modules.  After it is shown to be simple
> to get started in a multi-module code base, then all the refinements
> can be explained and added, but by then people are already using the
> logger, and learning becomes incremental.

Just a note: after spacing out over this thread for a bit, I thought I'd
try out logging, which I'd never tried before, in some code I was
writing.  I added a couple of lines like

    logging.info("foo is %s", foo)

where I'd usually write

    sys.stderr.write("foo is %s\n" % foo)

Liked it just fine -- easier to write.  But nothing came out!  Because
it's got this odd idea (from Java?) about "severities" of messages, and
by default passes nothing less "threatening" than warnings, because
logger.root is initialized by default to WARNING.

So, still a bit disconcerting for newbies.


More information about the Python-Dev mailing list