Commit 3e22d5de authored by Chris McDonough's avatar Chris McDonough

Refactor start_zope function and add tests for its functionality.

Changes:

 - startup log handler now pays attention to the logging levels of
   the handlers defined within the config file and uses the "lowest"
   level to log messages to stdout during startup.

 - entirely removed warning when the starting user's umask is "too
   permissive".  it wasn't clear that it added any value under normal
   operations.

 - replaced ancient setuid code with code stolen from zdaemon that
   works the same but looks nicer.
parent 027730b2
This diff is collapsed.
This diff is collapsed.
......@@ -142,8 +142,8 @@ class ZopeCmd(ZDCmd):
'opts.realize(); '
'h.handleConfig(opts.configroot,opts.confighandlers);'
'config.setConfiguration(opts.configroot); '
'from Zope.Startup import do_posix_stuff; '
'do_posix_stuff(opts.configroot); '%
'from Zope.Startup import dropPrivileges; '
'dropPrivileges(opts.configroot); '%
(python, self.options.configfile)
)
return cmdline + more + '\"'
......
......@@ -97,6 +97,9 @@ class HandlerFactory(Factory):
logger.setLevel(self.section.level)
return logger
def getLevel(self):
return self.section.level
class FileHandlerFactory(HandlerFactory):
def create_loghandler(self):
from zLOG.LogHandlers import StreamHandler, FileHandler
......@@ -224,3 +227,14 @@ class EventLogFactory(Factory):
from zLOG.LogHandlers import NullHandler
logger.addHandler(NullHandler())
return logger
def getLowestHandlerLevel(self):
""" Return the lowest log level provided by any of our handlers
(used by Zope startup logger code to decide what to send
to stderr during startup) """
lowest = self.level
for factory in self.handler_factories:
handler_level = factory.getLevel()
if handler_level < lowest:
lowest = factory.getLevel()
return lowest
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment