Unification of logging in Python's Standard Library

A.M. Kuchling amk at amk.ca
Tue Aug 19 12:18:34 EDT 2003


On Tue, 19 Aug 2003 10:06:26 -0500, 
	Skip Montanaro <skip at pobox.com> wrote:
>     Matthew> A single, unified logging system across the entire Python
>     Matthew> Standard Library would be a worthy goal for some future release
>     Matthew> (Python 3000, or maybe even 2.4/2.5?).
> Another alternative is to write a PEP, though I don't think this is
> necessarily required for this particular task.  It also presents a higher
> barrier to action than a bug report.

I suspect a PEP is required, because there are more issues here than just
changing sys.stderr.write() to logging.info().  For example, what logger
should modules use to log messages?  If they use the root logger, it will be
difficult to discard messages from asyncore while keeping messages from the
ZODB.  If they use a particular logger, how is this name chosen?  Is it
dependent on the module name, so asyncore logs to 'asyncore' and so forth?
What if my application has a logger named 'network', and I want it to go to
'network.asyncore', 'database.ZODB', etc.?

If the user specifies a logger, how is this done?  Does every public method
have to grow an optional 'log' argument, or is there a module-level global
setting, so you'd call
asyncore.set_logger(logging.getLogger('network.asyncore'))?  

None of these options are very difficult to implement, but choosing which
one will take some care; otherwise we'll be saddled with an inconvenient
implementation that we'll be forever working around.

--amk




More information about the Python-list mailing list