[Python-Dev] PEP 282: A Logging System -- comments please

Mark Hammond mhammond@skippinet.com.au
Sat, 9 Mar 2002 13:45:37 +1100


> I would appreciate any comments you might have on this proposal
> for adding a
> logging system to the Python Standard Library. This PEP is still an early
> draft so please forward your comments just to me directly for now.

Better late than never :)

I think the PEP looks good!

Re filters:  I agree that we need not go as far as ipchains, and no one has
said we should.  So change that text accordingly.  ie, the "The latter is
modeled" para can just be a quick not that log4j does it differently, but we
have opted for the simpler solution".

> "XXX How to defined a nice convenience function for logging an exception?
>       mx.Log has something like this, doesn't it?

I would suggest simply:
   def exception(self, msg, *args):
      This is almost identical to error(), but sys.exc_info() is
      called, and if available the exception details are appended
      to msg.  As sys.exc_info() is called, this is only useful in
      an exception handler.

If that isn't good enough, using traceback with StringIO is pretty easy to
create your own log message.

> XXX What about a .raising() convenience function?  How about:

Not convinced we need it.  An error() call is pretty good, and hopefully
will still stand out like a sore thumb.  In general, I would expect a
.error() call to be followed by an exception, or some other severe failure
anyway, so is kinda redundant.

>
>  What Logging Levels?
>
>    The following are the logging levels defined by the systems I looked
at:
>
>    - log4j: DEBUG, INFO, WARN, ERROR, FATAL
>...
>    The current proposal is to copy log4j.  XXX I suppose I could see
>    adding zLOG's "TRACE" level, but I am not sure of the usefulness
>    of others.

    I agree 100%  No need for TRACE either.  What is a TRACE message?  It is
a debug message.  Filtering should be done primarily via the module, not the
level.  (I loved "SYSTEM_UNIMPORTANT" - if it is unimportant, then don't
have it:)

> Static Logging Methods (as per Syslog)?

I quite like the idea of a simple:
            import logging
            logging.error("Something is wrong")

and worse, I quite like the idea of pulling namespace hacks so that a
reasonable module name is used.  Walking the stack until you find '__name__'
in your globals is a good default ;)

Good job!

Mark.