[CalendarServer-changes] [341]
CalendarServer/trunk/twistedcaldav/logging.py
source_changes at macosforge.org
source_changes at macosforge.org
Tue Oct 31 09:37:21 PST 2006
Revision: 341
http://trac.macosforge.org/projects/calendarserver/changeset/341
Author: cdaboo at apple.com
Date: 2006-10-31 09:37:20 -0800 (Tue, 31 Oct 2006)
Log Message:
-----------
Add authentication/authorization details into the access log.
Modified Paths:
--------------
CalendarServer/trunk/twistedcaldav/logging.py
Modified: CalendarServer/trunk/twistedcaldav/logging.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/logging.py 2006-10-31 16:35:33 UTC (rev 340)
+++ CalendarServer/trunk/twistedcaldav/logging.py 2006-10-31 17:37:20 UTC (rev 341)
@@ -25,6 +25,8 @@
import time
from twisted.python import log
+from twisted.web2 import iweb
+from twisted.web2.dav import davxml
from twisted.web2.log import BaseCommonAccessLoggingObserver
#
@@ -117,6 +119,41 @@
self.rotate()
self.f.write(message + '\n')
+ def emit(self, eventDict):
+ if eventDict.get('interface') is not iweb.IRequest:
+ return
+
+ request = eventDict['request']
+ response = eventDict['response']
+ loginfo = eventDict['loginfo']
+ firstLine = '%s %s HTTP/%s' %(
+ request.method,
+ request.uri,
+ '.'.join([str(x) for x in request.clientproto]))
+
+ # Try to determine authentication and authorization identifiers
+ uid = "-"
+ if hasattr(request, "authnUser"):
+ if isinstance(request.authnUser.children[0], davxml.HRef):
+ uid = str(request.authnUser.children[0])
+ if hasattr(request, "authzUser") and str(request.authzUser.children[0]) != uid:
+ uid += " as %s" % (str(request.authzUser.children[0]),)
+
+
+ self.logMessage(
+ '%s - %s [%s] "%s" %s %d "%s" "%s"' %(
+ request.remoteAddr.host,
+ uid,
+ self.logDateString(
+ response.headers.getHeader('date', 0)),
+ firstLine,
+ response.code,
+ loginfo.bytesSent,
+ request.headers.getHeader('referer', '-'),
+ request.headers.getHeader('user-agent', '-')
+ )
+ )
+
def start(self):
"""
Start logging. Open the log file and log an 'open' message.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20061031/8dcdaadd/attachment.html
More information about the calendarserver-changes
mailing list