Commit 936142ec authored by Fred Drake's avatar Fred Drake

Use the logging configuration component from ZConfig instead of the zLOG

implementation.  The configuration aspects of zLOG are about to disappear.
parent a284cc49
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
<!-- Use the ZEO server information structure. --> <!-- Use the ZEO server information structure. -->
<import package="ZEO"/> <import package="ZEO"/>
<import package="zLOG"/> <import package="ZConfig.components.logger"/>
<!-- runner control --> <!-- runner control -->
<import package="zdaemon"/> <import package="zdaemon"/>
......
...@@ -18,6 +18,7 @@ import sys ...@@ -18,6 +18,7 @@ import sys
import time import time
import errno import errno
import socket import socket
import logging
import StringIO import StringIO
import tempfile import tempfile
...@@ -55,11 +56,55 @@ class ZEOConfig: ...@@ -55,11 +56,55 @@ class ZEOConfig:
print >> f, "authentication-realm", self.authentication_realm print >> f, "authentication-realm", self.authentication_realm
print >> f, "</zeo>" print >> f, "</zeo>"
logger = logging.getLogger()
print >> f
print >> f, "<eventlog>"
print >> f, "level", logger.level
for handler in logger.handlers:
if isinstance(handler, logging.FileHandler):
path = handler.baseFilename
elif isinstance(handler, logging.StreamHandler):
stream = handler.stream
if stream.name == "<stdout>":
path = "STDOUT"
elif stream.name == "<stderr>":
path = "STDERR"
else:
# just drop it on the floor; unlikely an issue when testing
continue
else:
# just drop it on the floor; unlikely an issue when testing
continue
# This doesn't convert the level values to names, so the
# generated configuration isn't as nice as it could be,
# but it doesn't really need to be.
print >> f, "<logfile>"
print >> f, "level", handler.level
print >> f, "path ", path
if handler.formatter:
formatter = handler.formatter
if formatter._fmt:
print >> f, "format", encode_format(formatter._fmt)
if formatter.datefmt:
print >> f, "dateformat", encode_format(formatter.datefmt)
print >> f, "</logfile>"
print >> f, "</eventlog>"
def __str__(self): def __str__(self):
f = StringIO.StringIO() f = StringIO.StringIO()
self.dump(f) self.dump(f)
return f.getvalue() return f.getvalue()
def encode_format(fmt):
# The list of replacements mirrors
# ZConfig.components.logger.handlers._control_char_rewrites
for xform in (("\n", r"\n"), ("\t", r"\t"), ("\b", r"\b"),
("\f", r"\f"), ("\r", r"\r")):
fmt = fmt.replace(*xform)
return fmt
def start_zeo_server(storage_conf, zeo_conf, port, keep=0): def start_zeo_server(storage_conf, zeo_conf, port, keep=0):
"""Start a ZEO server in a separate process. """Start a ZEO server in a separate process.
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
<!-- Use the ZEO server information structure. --> <!-- Use the ZEO server information structure. -->
<import package="ZEO"/> <import package="ZEO"/>
<import package="zLOG"/> <import package="ZConfig.components.logger"/>
<!-- runner control --> <!-- runner control -->
<import package="zdaemon"/> <import package="zdaemon"/>
......
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