[Python-Dev] PEP282 and the warnings framework

Steven Lott s_lott@yahoo.com
Fri, 17 May 2002 03:24:39 -0700 (PDT)


> [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")
> 
[snip]

ouch.  That is too cumbersome to be an essential feature.  When 
debugging a fairly sophisticated class, some methods deserve 
their own subjects.  This would be awfully complex to create a 
channel/logger instance for each interesting method.

It would be much more useful to have a 
A) truly Singleton logger instance.
B) the ability to specify subject, severity, etc. as part of 
the object being logged; via a simple log.log() method that
accepts an Event instance.  A default subject would be used for
people who didn't provide one in the constructor.
C) the ability to use method names or arguments to fill in part
of an Event object; log.warn(), for example would fill in the
module-specified warning severity;
log.log(...,severity=logging.WARN) for those who prefer fewer
methods with more options.
D) the ability to create an Event object out of a standard
Exception instance (filling in subject and severity
automatically)
E) the ability to construct a "this class" or "this module"
accessor as shown above that would fill in the subject for 
people who found the "channel" model helpful.

Items A-D would be the core logger, maximum flexibility, minimal
implementation.  Item E would add a feature to the above model
that some people find useful.


=====
--
S. Lott, CCP :-{)
S_LOTT@YAHOO.COM
http://www.mindspring.com/~slott1
Buccaneer #468: KaDiMa

Macintosh user: drinking upstream from the herd.

__________________________________________________
Do You Yahoo!?
LAUNCH - Your Yahoo! Music Experience
http://launch.yahoo.com