[Zope3-checkins] SVN: Zope3/trunk/ Fixed bug 152 and 114:
"redirects with large HML" and "logging http
Christian Theune
ct at gocept.com
Fri Dec 2 18:56:05 EST 2005
Log message for revision 40513:
Fixed bug 152 and 114: "redirects with large HML" and "logging http
disconnects". Added an observer for twisted's log that routes error messages to
the python logging facility for "twisted" on DEBUG level.
Changed:
U Zope3/trunk/doc/CHANGES.txt
U Zope3/trunk/src/zope/app/twisted/log.py
U Zope3/trunk/src/zope/app/twisted/main.py
-=-
Modified: Zope3/trunk/doc/CHANGES.txt
===================================================================
--- Zope3/trunk/doc/CHANGES.txt 2005-12-02 23:40:22 UTC (rev 40512)
+++ Zope3/trunk/doc/CHANGES.txt 2005-12-02 23:56:04 UTC (rev 40513)
@@ -162,6 +162,10 @@
Bug Fixes
+ - Fixed bug 152 and 114: "redirects with large HML" and "logging http
+ disconnects". Added an observer for twisted's log that routes error
+ messages to the python logging facility for "twisted" on DEBUG level.
+
- Fixed bug 185: Keyword Index isinstance check fails on security proxy
- Improved bug 199: ZPTPage macro expansion
Modified: Zope3/trunk/src/zope/app/twisted/log.py
===================================================================
--- Zope3/trunk/src/zope/app/twisted/log.py 2005-12-02 23:40:22 UTC (rev 40512)
+++ Zope3/trunk/src/zope/app/twisted/log.py 2005-12-02 23:56:04 UTC (rev 40513)
@@ -24,7 +24,6 @@
import twisted.web2.log
from twisted import web2
-
class CommonAccessLoggingObserver(web2.log.BaseCommonAccessLoggingObserver):
"""Writes common access log to python's logging framework."""
@@ -50,3 +49,36 @@
)
self.output.logRequest(task.channel.addr[0], message)
+
+class PythonLoggingObserver:
+ """Bridges twisted's log messages for the event log.
+ """
+
+ def __init__(self):
+ # Twisted gets it's own system
+ self.logger = logging.getLogger("twisted")
+
+ def __call__(self, log_entry):
+ """Receive a twisted log entry, format it and bridge it to python."""
+ message = log_entry['message']
+ if not message:
+ if log_entry['isError'] and log_entry.has_key('failure'):
+ text = log_entry['failure'].getTraceback()
+ elif log_entry.has_key('format'):
+ try:
+ text = log_entry['format'] % eventDict
+ except KeyboardInterrupt:
+ raise
+ except:
+ try:
+ text = ('Invalid format string in log message: %s'
+ % log_entry)
+ except:
+ text = 'UNFORMATTABLE OBJECT WRITTEN TO LOG, MESSAGE LOST'
+ else:
+ # we don't know how to log this
+ return
+ else:
+ text = '\n\t'.join(map(str, message))
+ self.logger.debug(text)
+
Modified: Zope3/trunk/src/zope/app/twisted/main.py
===================================================================
--- Zope3/trunk/src/zope/app/twisted/main.py 2005-12-02 23:40:22 UTC (rev 40512)
+++ Zope3/trunk/src/zope/app/twisted/main.py 2005-12-02 23:56:04 UTC (rev 40513)
@@ -118,6 +118,7 @@
options.accesslog()
# Setup the logs. Eventually this might be better done using utilities.
+ twisted.python.log.addObserver(log.PythonLoggingObserver())
observer = log.CommonAccessLoggingObserver()
observer.start()
More information about the Zope3-Checkins
mailing list