PEP 282: A Logging System -- comments please

Edward K. Ream edream at tds.net
Sat Mar 9 10:54:28 EST 2002


I'd like to say a few more words about the proposed logger class.  These
will be my last words on this subject.

No other Python Module does as little, in essence, as would the logger
class.  Indeed, the heart of the proposed logger class is:

  if self.isEnabledForLevel(level):
    self.put(aString)

If the logger class used dynamic tracing, its essence would be:

  if self.tracePointMatchesDict(tracepoint):
    self.put(aString)
	
A logger class should reflect the simplicity of the problem.  Forget
convenience methods: it is trivial to define them in any scenario. 
Forget control flow, levels, loggers and configuration: dynamic tracing
suffices. Forget handlers, just provide a "put" method that can be
overridden in subclasses.

IMO, the present logging proposal is bad design because it solves an
easy problem in a complex way, like using a sledge hammer to kill a
fly when a fly swatter is readily at hand.  Regardless of precedents, a
logger class would clash with Python's usual elegance.  If the logging
class is going to exist, keep it simple and base it on dynamic tracing.

For an example of a simple dynamic tracing function that is more useful
than the proposed logging class, see the trace function and its allies
init_trace and get_Sherlock_args in leoUtils.py:
  http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/leo/leo/leoUtils.py
Extensive comments precede the get_Sherlock_args routine, which BTW
easily provides configuration.

Edward
--------------------------------------------------------------------
Edward K. Ream   email:  edream at tds.net
Leo: Literate Editor with Outlines
Leo: http://personalpages.tds.net/~edream/front.html
--------------------------------------------------------------------



More information about the Python-list mailing list