Commit 05aa5cd0 authored by Fred Drake's avatar Fred Drake

Change the name "logger" to "eventlog". Also rename the loghandler section

types.
parent b595b063
......@@ -54,12 +54,12 @@ zeo_conf_template = """# ZEO configuration file
path %(home)s/var/Data.fs
</filestorage>
<logger>
<eventlog>
level info
<logfile>
path %(home)s/log/zeo.log
</logfile>
</logger>
</eventlog>
"""
runner_conf_template = """# runner configuration file
......
......@@ -93,7 +93,7 @@ class ZEOOptionsMixin:
class ZEOOptions(ZDOptions, ZEOOptionsMixin):
logsectionname = "logger"
logsectionname = "eventlog"
def __init__(self):
self.schemadir = os.path.dirname(ZEO.__file__)
......
......@@ -27,6 +27,6 @@
</description>
</multisection>
<section name="*" type="logger" attribute="logger" required="no" />
<section name="*" type="eventlog" attribute="eventlog" required="no" />
</schema>
......@@ -27,14 +27,14 @@
datatype=".log_format"/>
</sectiontype>
<sectiontype name="nteventlog" datatype=".nteventlog_handler"
<sectiontype name="win32-eventlog" datatype=".nteventlog_handler"
implements="loghandler" extends="base-log-handler">
<key name="appname" default="Zope"/>
<key name="format" default="%(message)s"
datatype=".log_format"/>
</sectiontype>
<sectiontype name="http_handler" datatype=".http_handler"
<sectiontype name="http-logger" datatype=".http_handler"
implements="loghandler" extends="base-log-handler">
<key name="url" default="localhost" datatype=".http_handler_url"/>
<key name="method" default="GET" datatype=".get_or_post"/>
......@@ -42,7 +42,7 @@
datatype=".log_format"/>
</sectiontype>
<sectiontype name="smtp_handler" datatype=".smtp_handler"
<sectiontype name="email-notifier" datatype=".smtp_handler"
implements="loghandler" extends="base-log-handler">
<key name="fromaddr" required="yes"/>
<multikey name="toaddr" required="yes" attribute="toaddrs"/>
......@@ -52,17 +52,8 @@
datatype=".log_format"/>
</sectiontype>
<!--
<sectiontype name="custom_handler" datatype=".custom_handler"
implements="loghandler">
<key name="constructor" datatype="constructor" required="yes"/>
<key name="formatter" datatype="constructor"
default="logging.Formatter()"/>
<key name="level" default="info" datatype=".logging_level"/>
</sectiontype>
-->
<sectiontype name="logger" datatype=".logger">
<sectiontype name="eventlog" datatype=".EventLogFactory">
<key name="level" datatype=".logging_level" default="all"/>
<multisection type="loghandler" attribute="handlers" name="*"/>
</sectiontype>
......
......@@ -211,25 +211,10 @@ def smtp_handler(section):
section.toaddrs,
section.subject)
## def custom_handler(section):
## formatter_klass, formatter_pos, formatter_kw = section.formatter
## handler_klass, handler_pos, handler_kw = section.constructor
## level = section.level
## formatter = Factory(formatter_klass, None, formatter_pos, formatter_kw)
## def callback(inst, formatter=formatter, level=level):
## inst.setFormatter(formatter())
## inst.setLevel(level)
## return Factory(handler_klass, callback, *handler_pos, **handler_kw)
def logger(section):
return LoggerWrapper(section.level, section.handlers)
_marker = []
class LoggerWrapper:
class EventLogFactory:
"""
A wrapper used to create loggers while delaying actual logger
instance construction. We need to do this because we may
......@@ -238,9 +223,9 @@ class LoggerWrapper:
An instance of this wrapper is a callable which, when called, returns a
logger object.
"""
def __init__(self, level, handler_factories):
self.level = level
self.handler_factories = handler_factories
def __init__(self, section):
self.level = section.level
self.handler_factories = section.handlers
self.resolved = _marker
def __call__(self):
......
......@@ -31,7 +31,7 @@ class TestzLOGConfig(unittest.TestCase):
_schematext = """
<schema>
<import package='zLOG'/>
<section type='logger' name='*' attribute='logger'/>
<section type='eventlog' name='*' attribute='eventlog'/>
</schema>
"""
......@@ -62,10 +62,10 @@ class TestzLOGConfig(unittest.TestCase):
def test_config_without_logger(self):
conf = self.get_config("")
self.assert_(conf.logger is None)
self.assert_(conf.eventlog is None)
def test_config_without_handlers(self):
logger = self.check_simple_logger("<logger/>")
logger = self.check_simple_logger("<eventlog/>")
# Make sure there's a NullHandler, since a warning gets
# printed if there are no handlers:
self.assertEqual(len(logger.handlers), 1)
......@@ -74,12 +74,12 @@ class TestzLOGConfig(unittest.TestCase):
def test_with_logfile(self):
fn = tempfile.mktemp()
logger = self.check_simple_logger("<logger>\n"
logger = self.check_simple_logger("<eventlog>\n"
" <logfile>\n"
" path %s\n"
" level debug\n"
" </logfile>\n"
"</logger>" % fn)
"</eventlog>" % fn)
# Make sure there's exactly one handler, since a warning gets
# printed if there are no handlers, and we don't want an
# unnecessary NullHandler getting added:
......@@ -92,9 +92,9 @@ class TestzLOGConfig(unittest.TestCase):
def check_simple_logger(self, text, level=logging.NOTSET):
conf = self.get_config(text)
self.assertEqual(conf.logger.level, level)
self.assert_(conf.logger is not None)
logger = conf.logger()
self.assert_(conf.eventlog is not None)
self.assertEqual(conf.eventlog.level, level)
logger = conf.eventlog()
self.assert_(isinstance(logger, logging.Logger))
return logger
......
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