[Python-Dev] PEP282 and the warnings framework

Vinay Sajip vinay_sajip@red-dove.com
Thu, 16 May 2002 22:58:32 +0100


[Steven Lott]
> How does a "channel" offer subject area filtering?

I'm using the term "logger" and "channel" interchangeably. You name your
loggers after your subject areas. For example - "search.indexing",
"search.query", "search.stats" for the search portion of an application.

idxlog = logging.getLogger("search.indexing")
qrylog = logging.getLogger("search.query")
statlog = logging.getLogger("search.stats")

> How do I get a single log with some subjects enabled
> and some subjects disabled?

For example,

idxlog.setLevel(logging.DEBUG)
qrylog.setLevel(logging.CRITICAL)
statlog.setLevel(logging.ERROR)
...
idxlog.info("Hello")    #gets logged
qrylog.error("My bad!") #gets dropped
statlog.warn("Watch it!") #gets dropped
statlog.error("Too late!") #gets logged

and so on.

>
> Actually it is more than this.  Much more.
[Ideas on event-driven apps snipped]

Some of your ideas echo those suggested by Richard Jones a little while
ago - see http://mechanicalcat.net/tech/pylogging for his ideas. He took the
idea as far as creating an experimental logging hub; as far as I know he had
relatively few problems building on top of logging.py.

 Regards


Vinay