[Zope-Checkins] CVS: Releases/Zope/lib/python/zLOG - __init__.py:1.14
Guido van Rossum
guido@python.org
Tue, 26 Nov 2002 11:30:27 -0500
Update of /cvs-repository/Releases/Zope/lib/python/zLOG
In directory cvs.zope.org:/tmp/cvs-serv20086
Modified Files:
__init__.py
Log Message:
The first call to LOG() calls initialize(), so that (like before
ChrisM's changes here) it is no longer necessary to call
zLOG.initialize() in order to see logging output.
=== Releases/Zope/lib/python/zLOG/__init__.py 1.13 => 1.14 ===
--- Releases/Zope/lib/python/zLOG/__init__.py:1.13 Sun Nov 24 00:24:43 2002
+++ Releases/Zope/lib/python/zLOG/__init__.py Tue Nov 26 11:30:26 2002
@@ -89,7 +89,7 @@
__version__='$Revision$'[11:-2]
from EventLogger import log_write, log_time, severity_string, \
- initialize_from_environment as initialize
+ initialize_from_environment
from traceback import format_exception
# Standard severities
@@ -102,6 +102,14 @@
ERROR = 200
PANIC = 300
+# Flag indicating whether LOG() should call initialize()
+_call_initialize = 1
+
+def initialize():
+ global _call_initialize
+ _call_initialize = 0
+ initialize_from_environment()
+
def LOG(subsystem, severity, summary, detail='', error=None, reraise=None):
"""Log some information
@@ -127,6 +135,9 @@
error is reraised.
"""
+ _call_initialize
+ if _call_initialize:
+ initialize()
log_write(subsystem, severity, summary, detail, error)
if reraise and error:
raise error[0], error[1], error[2]