[Zope-Coders] new zLOG

Jeremy Hylton jeremy@zope.com (Jeremy Hylton)
Mon, 25 Nov 2002 11:00:48 -0500


>>>>> "CM" == Chris McDonough <chrism@zope.com> writes:

  CM> Yes, it is intentional.. sorry I should have mentioned this and
  CM> made it explicit in the changelog.  If "import zLOG" potentially
  CM> causes a file to be written, it is difficult to control when it
  CM> is "safe" to import.  Can you live with this?

It seems like a big change as far as backwards compatibility goes.
I imagine it could be hard to go through an existing application and
make sure the first use of zLOG to generate logging data is preceded
by a call to initialize() -- without calling initialize everywhere
zLOG is initialized.

The logging package just works without an explicit initialization
call.

> A Simple Example
> 
> Using the package doesn't get much simpler. It is packaged as a
> standard Python package called (unsurprisingly) logging. You just need
> to import logging and you're ready to go. Minimal example:
> 
> # --- app.py -----------------------------------------------------------
> import logging
> 
> logging.warn("Hello")
> logging.error("Still here...")
> logging.warn("Goodbye")
> 
> When you run app.py, the results are:
> 
> WARN:root:Hello
> ERROR:root:Still here...
> WARN:root:Goodbye

I don't like imports with side-effects in general, but they seem
useful for this particular application.

Jeremy