Skip to content.

plope

Personal tools
You are here: Home » Members » chrism's Home » The Python 'logging' Module Gives Me the Blues
 
 

The Python 'logging' Module Gives Me the Blues

I'm sad about logging.

Phillip Eby wrote some on this before. I have my own list of complaints about the PEP 282 logging implementation.

First-class complaints:

  • Never, ever, ever should a library print anything to stdout or stderr.
  • Never, ever, ever should a library think it knows enough to register an atexit handler that calls potentially arbitrary code at interpreter shutdown.
  • Never, ever should a library that allows you to pass a format string to it for serialization purposes add any other characters to the serialization outside the format string (the logging module adds a linefeed to all message emissions).

Second-class complaints:

  • Libraries should not maintain global registries as a side effect of calling a constructor. I give asyncore a pass on this, so I won't be hypocritical and put this in "first-class complaints" ;-)
  • Relatively simple libraries like this should not try to do thread locking. I'd rather not pay the performance price for this if I'm not using threads.

It might have been easier to write my own logging facility than to write this post.

Created by chrism
Last modified 2007-09-03 01:31 AM

aaaannnddd....

> It might have been easier to write my own logging facility than to write this post.

Aaaaaand... that's what I did... http://cvs.plope.com/viewcvs/Packages/supervisor2/src/supervisor/loggers.py?rev=1.6&content-type=text/vnd.viewcvs-markup

Logging blues

As original author and current maintainer of Python's logging package, I'm very sorry that Python's logging implementation causes you pain.

But ... "Never, ever, ..." is a little too dogmatic for my taste. There are fairly good reasons for all of the design decisions which you complain about; before being accepted into Python, the logging package went through a reasonable amount of peer review on python-dev. I don't believe that you can please all the people even some of the time; and I'd be surprised if the logging package is the only one in the Python stdlib where similar design decisions have been made. If you were just letting off steam, fine - but if you look at svn logs you'll see I've been reasonable about accepting patches and suggestions to improve the package. Of course, I'm now constrained by the need to maintain backward compatibility...