[Zope-Checkins] CVS: Zope/lib/python/Zope/Startup -
__init__.py:1.18 datatypes.py:1.18
Fred L. Drake, Jr.
fred at zope.com
Tue Apr 13 15:02:26 EDT 2004
Update of /cvs-repository/Zope/lib/python/Zope/Startup
In directory cvs.zope.org:/tmp/cvs-serv32680/Zope/Startup
Modified Files:
__init__.py datatypes.py
Log Message:
- fix up the last piece that dealt with the old zLOG cruft; this is more
loosely coupled and re-uses the shared logging configuration more
- replace uses of zLOG with logging
=== Zope/lib/python/Zope/Startup/__init__.py 1.17 => 1.18 ===
--- Zope/lib/python/Zope/Startup/__init__.py:1.17 Tue Apr 13 13:39:47 2004
+++ Zope/lib/python/Zope/Startup/__init__.py Tue Apr 13 15:02:25 2004
@@ -22,10 +22,11 @@
import ZConfig
+logger = logging.getLogger("Zope")
started = False
def start_zope(cfg):
- """ The function called by run.py which starts a Zope appserver """
+ """The function called by run.py which starts a Zope appserver."""
global started
if started:
# dont allow any code to call start_zope twice.
@@ -73,28 +74,29 @@
started = False
class ZopeStarter:
- """ This is a class which starts a Zope server. Making it a class
- makes it easier to unit test. """
+ """This is a class which starts a Zope server.
+
+ Making it a class makes it easier to test.
+ """
def __init__(self, cfg):
self.cfg = cfg
self.event_logger = logging.getLogger()
def info(self, msg):
- import zLOG
- zLOG.LOG('Zope', zLOG.INFO, msg)
+ logger.info(msg)
def panic(self, msg):
- import zLOG
- zLOG.LOG('Zope', zLOG.PANIC, msg)
+ logger.critical(msg)
def error(self, msg):
- import zLOG
- zLOG.LOG('Zope', zLOG.ERROR, msg)
+ logger.error(msg)
def registerSignals(self):
if os.name == 'posix':
from Signals import Signals
- Signals.registerZopeSignals()
+ Signals.registerZopeSignals([self.cfg.eventlog,
+ self.cfg.access,
+ self.cfg.trace])
def setupSecurityOptions(self):
import AccessControl
@@ -300,7 +302,6 @@
if os.getuid() != 0:
return
- import zLOG
import pwd
effective_user = cfg.effective_user
@@ -308,7 +309,7 @@
msg = ('A user was not specified to setuid to; fix this to '
'start as root (change the effective-user directive '
'in zope.conf)')
- zLOG.LOG('Zope', zLOG.PANIC, msg)
+ logger.critical(msg)
raise ZConfig.ConfigurationError(msg)
try:
@@ -318,7 +319,7 @@
pwrec = pwd.getpwnam(effective_user)
except KeyError:
msg = "Can't find username %r" % effective_user
- zLOG.LOG("Zope", zLOG.ERROR, msg)
+ logger.error(msg)
raise ZConfig.ConfigurationError(msg)
uid = pwrec[2]
else:
@@ -326,13 +327,13 @@
pwrec = pwd.getpwuid(uid)
except KeyError:
msg = "Can't find uid %r" % uid
- zLOG.LOG("Zope", zLOG.ERROR, msg)
+ logger.error(msg)
raise ZConfig.ConfigurationError(msg)
gid = pwrec[3]
if uid == 0:
msg = 'Cannot start Zope with the effective user as the root user'
- zLOG.LOG('Zope', zLOG.INFO, msg)
+ logger.error(msg)
raise ZConfig.ConfigurationError(msg)
try:
@@ -340,11 +341,8 @@
initgroups.initgroups(effective_user, gid)
os.setgid(gid)
except OSError:
- zLOG.LOG("Zope", zLOG.INFO,
- 'Could not set group id of effective user',
- error=sys.exc_info())
+ logger.exception('Could not set group id of effective user')
os.setuid(uid)
- zLOG.LOG("Zope", zLOG.INFO,
- 'Set effective user to "%s"' % effective_user)
+ logger.info('Set effective user to "%s"' % effective_user)
return 1 # for unit testing purposes
=== Zope/lib/python/Zope/Startup/datatypes.py 1.17 => 1.18 ===
--- Zope/lib/python/Zope/Startup/datatypes.py:1.17 Thu Mar 4 17:45:12 2004
+++ Zope/lib/python/Zope/Startup/datatypes.py Tue Apr 13 15:02:25 2004
@@ -15,6 +15,8 @@
"""Datatypes for the Zope schema for use with ZConfig."""
import os
+
+from ZConfig.components.logger import logger
from ZODB.config import ZODBDatabase
# generic datatypes
@@ -43,7 +45,7 @@
# Datatype for the access and trace logs
# (the loghandler datatypes come from the zLOG package)
-class LoggerFactory:
+class LoggerFactory(logger.LoggerFactory):
"""
A factory used to create loggers while delaying actual logger
instance construction. We need to do this because we may want to
@@ -53,24 +55,9 @@
object.
"""
def __init__(self, section):
- self.name = section.getSectionName()
- self.level = section.level
- self.handler_factories = section.handlers
- self.resolved = None
-
- def __call__(self):
- if self.resolved is None:
- # set the logger up
- import logging
- logger = logging.getLogger(self.name)
- logger.handlers = []
- logger.propagate = 0
- logger.setLevel(self.level)
- for handler_factory in self.handler_factories:
- handler = handler_factory()
- logger.addHandler(handler)
- self.resolved = logger
- return self.resolved
+ section.name = section.getSectionName()
+ section.propagate = False
+ logger.LoggerFactory.__init__(self, section)
# DNS resolver
More information about the Zope-Checkins
mailing list