[CalendarServer-changes] [1768] CalendarServer/trunk/twistedcaldav
source_changes at macosforge.org
source_changes at macosforge.org
Wed Aug 8 08:24:15 PDT 2007
Revision: 1768
http://trac.macosforge.org/projects/calendarserver/changeset/1768
Author: cdaboo at apple.com
Date: 2007-08-08 08:24:15 -0700 (Wed, 08 Aug 2007)
Log Message:
-----------
Make sure access logs display short names rather than full __uids__ principal paths.
Modified Paths:
--------------
CalendarServer/trunk/twistedcaldav/logging.py
CalendarServer/trunk/twistedcaldav/pdmonster.py
CalendarServer/trunk/twistedcaldav/tap.py
Modified: CalendarServer/trunk/twistedcaldav/logging.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/logging.py 2007-08-08 13:42:41 UTC (rev 1767)
+++ CalendarServer/trunk/twistedcaldav/logging.py 2007-08-08 15:24:15 UTC (rev 1768)
@@ -30,8 +30,10 @@
from twisted.web2 import iweb
from twisted.web2.dav import davxml
from twisted.web2.log import BaseCommonAccessLoggingObserver
+from twisted.web2.log import LogWrapperResource
from twistedcaldav.config import config
+from twistedcaldav.directory.directory import DirectoryService
#
# Logging levels:
@@ -100,6 +102,15 @@
if canLog("debug"):
log.msg(message, debug=True, **kwargs)
+class DirectoryLogWrapperResource(LogWrapperResource):
+
+ def __init__(self, resource, directory):
+ super(DirectoryLogWrapperResource, self).__init__(resource)
+
+ self.directory = directory
+
+ def getDirectory(self):
+ return self.directory
class CommonAccessLoggingObserverExtensions(BaseCommonAccessLoggingObserver):
"""
@@ -122,9 +133,31 @@
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 = '"%s as %s"' % (uid, request.authzUser.children[0])
+ uidn = str(request.authnUser.children[0])
+ uidz = None
+ if hasattr(request, "authzUser") and str(request.authzUser.children[0]) != uidn:
+ uidz = str(request.authzUser.children[0])
+
+ def convertUIDtoShortName(uid):
+ uid = uid.rstrip("/")
+ uid = uid[uid.rfind("/") + 1:]
+ record = request.site.resource.getDirectory().recordWithGUID(uid)
+ if record:
+ if record.recordType == DirectoryService.recordType_users:
+ return record.shortName
+ else:
+ return "(%s)%s" % (record.recordType, record.shortName,)
+ else:
+ return uid
+
+ uidn = convertUIDtoShortName(uidn)
+ if uidz:
+ uidz = convertUIDtoShortName(uidz)
+
+ if uidn and uidz:
+ uid = '"%s as %s"' % (uidn, uidz,)
+ else:
+ uid = uidn
self.logMessage(
'%s - %s [%s] "%s" %s %d "%s" "%s" [%.1f ms]' %(
Modified: CalendarServer/trunk/twistedcaldav/pdmonster.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/pdmonster.py 2007-08-08 13:42:41 UTC (rev 1767)
+++ CalendarServer/trunk/twistedcaldav/pdmonster.py 2007-08-08 15:24:15 UTC (rev 1768)
@@ -7,12 +7,17 @@
from twistedcaldav import logging
class PDClientAddressWrapper(WrapperResource):
- def __init__(self, resource, socket):
+ def __init__(self, resource, socket, directory):
super(PDClientAddressWrapper, self).__init__(resource)
self.socket = socket
self.client = None
self.protocol = None
+
+ self.directory = directory
+
+ def getDirectory(self):
+ return self.directory
def hook(self, request):
from twisted.internet import reactor
Modified: CalendarServer/trunk/twistedcaldav/tap.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/tap.py 2007-08-08 13:42:41 UTC (rev 1767)
+++ CalendarServer/trunk/twistedcaldav/tap.py 2007-08-08 15:24:15 UTC (rev 1768)
@@ -38,7 +38,6 @@
from twisted.web2.auth.basic import BasicCredentialFactory
from twisted.web2.channel import http
-from twisted.web2.log import LogWrapperResource
from twisted.web2.server import Site
from twistedcaldav import logging
@@ -506,7 +505,7 @@
(auth.IPrincipal,)
)
- logWrapper = LogWrapperResource(authWrapper)
+ logWrapper = logging.DirectoryLogWrapperResource(authWrapper, directory)
#
# Configure the service
@@ -518,7 +517,8 @@
if config.MultiProcess['ProcessCount'] > 1:
realRoot = pdmonster.PDClientAddressWrapper(
logWrapper,
- config.PythonDirector['ControlSocket']
+ config.PythonDirector['ControlSocket'],
+ directory
)
else:
realRoot = logWrapper
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20070808/a545dbd8/attachment.html
More information about the calendarserver-changes
mailing list