[Zodb-checkins] CVS: Zope/lib/python/zLOG - datatypes.py:1.16
Fred L. Drake, Jr.
fred at zope.com
Tue Jan 6 11:41:07 EST 2004
Update of /cvs-repository/Zope/lib/python/zLOG
In directory cvs.zope.org:/tmp/cvs-serv12758
Modified Files:
datatypes.py
Log Message:
improve code re-use: make use of the basic "eventlog" factory from
ZConfig.components.logger, adding only what's special about the zLOG
version of the factory
=== Zope/lib/python/zLOG/datatypes.py 1.15 => 1.16 ===
--- Zope/lib/python/zLOG/datatypes.py:1.15 Mon Jan 5 12:04:12 2004
+++ Zope/lib/python/zLOG/datatypes.py Tue Jan 6 11:41:04 2004
@@ -17,38 +17,16 @@
import zLOG
from zLOG import EventLogger
-from ZConfig.components.logger.factory import Factory
+from ZConfig.components.logger import logger
-class EventLogFactory(Factory):
- """
- A wrapper used to create loggers while delaying actual logger
- instance construction. We need to do this because we may
- want to reference a logger before actually instantiating it (for example,
- to allow the app time to set an effective user).
- An instance of this wrapper is a callable which, when called, returns a
- logger object.
- """
- def __init__(self, section):
- Factory.__init__(self)
- self.level = section.level
- self.handler_factories = section.handlers
+class EventLogFactory(logger.EventLogFactory):
+ """Factory used to create a logger to use with zLOG.
- def create(self):
- # set the logger up
- import logging
- logger = logging.getLogger("event")
- logger.handlers = []
- logger.propagate = 0
- logger.setLevel(self.level)
- if self.handler_factories:
- for handler_factory in self.handler_factories:
- handler = handler_factory()
- logger.addHandler(handler)
- else:
- from ZConfig.components.logger.loghandler import NullHandler
- logger.addHandler(NullHandler())
- return logger
+ This adds the getLowestHandlerLevel() method to make it suitable
+ for Zope and replaces the startup() method to ensure zLOG is
+ properly initialized.
+ """
def getLowestHandlerLevel(self):
""" Return the lowest log level provided by any of our handlers
More information about the Zodb-checkins
mailing list