Commit 60c53413 authored by Fred Drake's avatar Fred Drake

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

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