[Twisted-web] web2 log patch

Andrea Arcangeli andrea at cpushare.com
Thu Jan 19 19:35:38 MST 2006


This fixes a typo in CVS and adds a common handler for file logging:

Index: Twisted/twisted/web2/log.py
===================================================================
--- Twisted/twisted/web2/log.py	(revision 15644)
+++ Twisted/twisted/web2/log.py	(working copy)
@@ -137,7 +137,7 @@
         request = eventDict['request']
         response = eventDict['response']
         loginfo = eventDict['loginfo']
-        firstLine = '%s %s HTTP/%' %(
+        firstLine = '%s %s HTTP/%s' %(
             request.method,
             request.uri,
             '.'.join([str(x) for x in request.clientproto]))
@@ -166,6 +166,13 @@
         tlog.removeObserver(self.emit)
 
 
+class FileAccessLoggingObserver(BaseCommonAccessLoggingObserver):
+	def __init__(self, logpath):
+		self.f = file(logpath, 'a', 1)
+
+	def logMessage(self, message):
+		self.f.write(message + '\n')
+
 class DefaultCommonAccessLoggingObserver(BaseCommonAccessLoggingObserver):
     """Log requests to default twisted logfile."""
     def logMessage(self, message):



More information about the Twisted-web mailing list