[CalendarServer-changes] [11359] CalendarServer/trunk

source_changes at macosforge.org source_changes at macosforge.org
Thu Jun 13 17:19:17 PDT 2013


Revision: 11359
          http://trac.calendarserver.org//changeset/11359
Author:   sagen at apple.com
Date:     2013-06-13 17:19:16 -0700 (Thu, 13 Jun 2013)
Log Message:
-----------
Update logging

Modified Paths:
--------------
    CalendarServer/trunk/calendarserver/tap/util.py
    CalendarServer/trunk/twistedcaldav/directory/ldapdirectory.py
    CalendarServer/trunk/txdav/base/datastore/subpostgres.py

Modified: CalendarServer/trunk/calendarserver/tap/util.py
===================================================================
--- CalendarServer/trunk/calendarserver/tap/util.py	2013-06-13 23:42:13 UTC (rev 11358)
+++ CalendarServer/trunk/calendarserver/tap/util.py	2013-06-14 00:19:16 UTC (rev 11359)
@@ -288,7 +288,8 @@
     #
     if config.AugmentService.type:
         augmentClass = namedClass(config.AugmentService.type)
-        log.info("Configuring augment service of type: %s" % (augmentClass,))
+        log.info("Configuring augment service of type: {augmentClass}",
+            augmentClass=augmentClass)
         try:
             augmentService = augmentClass(**config.AugmentService.params)
         except IOError:
@@ -315,8 +316,8 @@
     directoryClass = namedClass(config.DirectoryService.type)
     principalResourceClass = DirectoryPrincipalProvisioningResource
 
-    log.info("Configuring directory service of type: %s"
-        % (config.DirectoryService.type,))
+    log.info("Configuring directory service of type: {directoryType}",
+        directoryType=config.DirectoryService.type)
 
     config.DirectoryService.params.augmentService = augmentService
     config.DirectoryService.params.groupMembershipCache = groupMembershipCache
@@ -334,7 +335,8 @@
     if config.ResourceService.Enabled:
         resourceClass = namedClass(config.ResourceService.type)
 
-        log.info("Configuring resource service of type: %s" % (resourceClass,))
+        log.info("Configuring resource service of type: {resourceClass}",
+            resourceClass=resourceClass)
 
         config.ResourceService.params.augmentService = augmentService
         config.ResourceService.params.groupMembershipCache = groupMembershipCache
@@ -369,8 +371,7 @@
         directory.setRealm(realmName)
     except ImportError:
         pass
-    log.info("Setting up principal collection: %r"
-                  % (principalResourceClass,))
+    log.info("Setting up principal collection: {cls}", cls=principalResourceClass)
     principalResourceClass("/principals/", directory)
     return directory
 
@@ -419,7 +420,7 @@
     #
     proxydbClass = namedClass(config.ProxyDBService.type)
 
-    log.info("Configuring proxydb service of type: %s" % (proxydbClass,))
+    log.info("Configuring proxydb service of type: {cls}", cls=proxydbClass)
 
     try:
         calendaruserproxy.ProxyDBService = proxydbClass(**config.ProxyDBService.params)
@@ -439,7 +440,7 @@
 
     realm = directory.realmName or ""
 
-    log.info("Configuring authentication for realm: %s" % (realm,))
+    log.info("Configuring authentication for realm: {realm}", realm=realm)
 
     for scheme, schemeConfig in config.Authentication.iteritems():
         scheme = scheme.lower()
@@ -447,7 +448,7 @@
         credFactory = None
 
         if schemeConfig["Enabled"]:
-            log.info("Setting up scheme: %s" % (scheme,))
+            log.info("Setting up scheme: {scheme}", scheme=scheme)
 
             if scheme == "kerberos":
                 if not NegotiateCredentialFactory:
@@ -483,7 +484,7 @@
                 pass
 
             else:
-                log.error("Unknown scheme: %s" % (scheme,))
+                log.error("Unknown scheme: {scheme}", scheme=scheme)
 
         if credFactory:
             wireEncryptedCredentialFactories.append(credFactory)
@@ -493,12 +494,12 @@
     #
     # Setup Resource hierarchy
     #
-    log.info("Setting up document root at: %s" % (config.DocumentRoot,))
+    log.info("Setting up document root at: {root}", root=config.DocumentRoot)
 
     principalCollection = directory.principalCollection
 
     if config.EnableCalDAV:
-        log.info("Setting up calendar collection: %r" % (calendarResourceClass,))
+        log.info("Setting up calendar collection: {cls}", cls=calendarResourceClass)
         calendarCollection = calendarResourceClass(
             directory,
             "/calendars/",
@@ -506,7 +507,7 @@
         )
 
     if config.EnableCardDAV:
-        log.info("Setting up address book collection: %r" % (addressBookResourceClass,))
+        log.info("Setting up address book collection: {cls}", cls=addressBookResourceClass)
         addressBookCollection = addressBookResourceClass(
             directory,
             "/addressbooks/",
@@ -515,7 +516,8 @@
 
         directoryPath = os.path.join(config.DocumentRoot, config.DirectoryAddressBook.name)
         if config.DirectoryAddressBook.Enabled and config.EnableSearchAddressBook:
-            log.info("Setting up directory address book: %r" % (directoryBackedAddressBookResourceClass,))
+            log.info("Setting up directory address book: {cls}",
+                cls=directoryBackedAddressBookResourceClass)
 
             directoryBackedAddressBookCollection = directoryBackedAddressBookResourceClass(
                 principalCollections=(principalCollection,)
@@ -528,12 +530,12 @@
             # remove /directory from previous runs that may have created it
             try:
                 FilePath(directoryPath).remove()
-                log.info("Deleted: %s" % directoryPath)
+                log.info("Deleted: {path}", path=directoryPath)
             except (OSError, IOError), e:
                 if e.errno != errno.ENOENT:
-                    log.error("Could not delete: %s : %r" % (directoryPath, e,))
+                    log.error("Could not delete: {path} : {error}", path=directoryPath, error=e)
 
-    log.info("Setting up root resource: %r" % (rootResourceClass,))
+    log.info("Setting up root resource: {cls}", cls=rootResourceClass)
 
     root = rootResourceClass(
         config.DocumentRoot,
@@ -582,9 +584,9 @@
 
     for name, info in config.Aliases.iteritems():
         if os.path.sep in name or not info.get("path", None):
-            log.error("Invalid alias: %s" % (name,))
+            log.error("Invalid alias: {name}", name=name)
             continue
-        log.info("Adding alias %s -> %s" % (name, info["path"]))
+        log.info("Adding alias {name} -> {path}", name=name, path=info["path"])
         resource = FileResource(info["path"])
         root.putChild(name, resource)
 
@@ -594,8 +596,8 @@
 
     # Timezone service is optional
     if config.EnableTimezoneService:
-        log.info("Setting up time zone service resource: %r"
-                      % (timezoneServiceResourceClass,))
+        log.info("Setting up time zone service resource: {cls}",
+                      cls=timezoneServiceResourceClass)
 
         timezoneService = timezoneServiceResourceClass(
             root,
@@ -604,8 +606,8 @@
 
     # Standard Timezone service is optional
     if config.TimezoneService.Enabled:
-        log.info("Setting up standard time zone service resource: %r"
-                      % (timezoneStdServiceResourceClass,))
+        log.info("Setting up standard time zone service resource: {cls}",
+                      cls=timezoneStdServiceResourceClass)
 
         timezoneStdService = timezoneStdServiceResourceClass(
             root,
@@ -622,8 +624,8 @@
     # iSchedule service
     #
     if config.Scheduling.iSchedule.Enabled:
-        log.info("Setting up iSchedule inbox resource: %r"
-                      % (iScheduleResourceClass,))
+        log.info("Setting up iSchedule inbox resource: {cls}",
+                      cls=iScheduleResourceClass)
 
         ischedule = iScheduleResourceClass(
             root,
@@ -634,7 +636,8 @@
         # Do DomainKey resources
         DKIMUtils.validConfiguration(config)
         if config.Scheduling.iSchedule.DKIM.Enabled:
-            log.info("Setting up domainkey resource: %r" % (DomainKeyResource,))
+            log.info("Setting up domainkey resource: {res}",
+                res=DomainKeyResource)
             domain = config.Scheduling.iSchedule.DKIM.Domain if config.Scheduling.iSchedule.DKIM.Domain else config.ServerHostName
             dk = DomainKeyResource(
                 domain,
@@ -647,8 +650,8 @@
     # WebCal
     #
     if config.WebCalendarRoot:
-        log.info("Setting up WebCalendar resource: %s"
-                      % (config.WebCalendarRoot,))
+        log.info("Setting up WebCalendar resource: {res}",
+                      res=config.WebCalendarRoot)
         webCalendar = webCalendarResourceClass(
             config.WebCalendarRoot,
             principalCollections=(principalCollection,),
@@ -674,8 +677,8 @@
     #
     apnConfig = config.Notifications.Services.APNS
     if apnConfig.Enabled:
-        log.info("Setting up APNS resource at /%s" %
-            (apnConfig["SubscriptionURL"],))
+        log.info("Setting up APNS resource at /{url}",
+            url=apnConfig["SubscriptionURL"])
         apnResource = apnSubscriptionResourceClass(root, newStore)
         root.putChild(apnConfig["SubscriptionURL"], apnResource)
 
@@ -706,7 +709,8 @@
                         schemeConfig["Qop"],
                         realm,
                     ))
-            log.info("Overriding %s with %s (%s)" % (path, cls, schemes))
+            log.info("Overriding {path} with {cls} ({schemes})",
+                path=path, cls=cls, schemes=schemes)
 
     authWrapper = AuthenticationWrapper(
         root,
@@ -932,11 +936,14 @@
                     try:
                         memory = self._memoryForPID(pid, self._residentOnly)
                     except Exception, e:
-                        log.error("Unable to determine memory usage of PID: %d (%s)" % (pid, e))
+                        log.error("Unable to determine memory usage of PID: {pid} ({err})",
+                            pid=pid, err=e)
                         continue
                     if memory > self._bytes:
-                        log.warn("Killing large process: %s PID:%d %s:%d" %
-                            (name, pid, "Resident" if self._residentOnly else "Virtual", memory))
+                        log.warn("Killing large process: {name} PID:{pid} {memtype}:{mem}",
+                            name=name, pid=pid,
+                            memtype=("Resident" if self._residentOnly else "Virtual"),
+                            mem=memory)
                         self._processMonitor.stopProcess(name)
         finally:
             self._delayedCall = self._reactor.callLater(self._seconds, self.checkMemory)

Modified: CalendarServer/trunk/twistedcaldav/directory/ldapdirectory.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/directory/ldapdirectory.py	2013-06-13 23:42:13 UTC (rev 11358)
+++ CalendarServer/trunk/twistedcaldav/directory/ldapdirectory.py	2013-06-14 00:19:16 UTC (rev 11359)
@@ -312,8 +312,9 @@
             filterstr = "(&%s%s)" % (filterstr, typeFilter)
 
         # Query the LDAP server
-        self.log.debug("Querying ldap for records matching base %s and filter %s for attributes %s." %
-            (ldap.dn.dn2str(base), filterstr, self.attrlist))
+        self.log.debug("Querying ldap for records matching base {base} and "
+            "filter {filter} for attributes {attrs}.", 
+            base=ldap.dn.dn2str(base), filter=filterstr, attrs=self.attrlist)
 
         # This takes a while, so if you don't want to have a "long request"
         # warning logged, use this instead of timedSearch:
@@ -332,21 +333,22 @@
 
             try:
                 record = self._ldapResultToRecord(dn, attrs, recordType)
-                # self.log.debug("Got LDAP record %s" % (record,))
+                # self.log.debug("Got LDAP record {record}", record=record)
             except MissingGuidException:
                 numMissingGuids += 1
                 continue
 
             if not unrestricted:
-                self.log.debug("%s is not enabled because it's not a member of group: %s" % (dn, self.restrictToGroup))
+                self.log.debug("{dn} is not enabled because it's not a member of group: {group}",
+                    dn=dn, group=self.restrictToGroup)
                 record.enabledForCalendaring = False
                 record.enabledForAddressBooks = False
 
             records.append(record)
 
         if numMissingGuids:
-            self.log.info("%d %s records are missing %s" %
-                (numMissingGuids, recordType, guidAttr))
+            self.log.info("{num} {recordType] records are missing {attr}",
+                num=numMissingGuids, recordType=recordType, attr=guidAttr)
 
         return records
 
@@ -391,8 +393,9 @@
         attrlist = [guidAttr, readAttr, writeAttr]
 
         # Query the LDAP server
-        self.log.debug("Querying ldap for records matching base %s and filter %s for attributes %s." %
-            (ldap.dn.dn2str(self.base), filterstr, attrlist))
+        self.log.debug("Querying ldap for records matching base {base} and "
+            "filter {filter} for attributes {attrs}.",
+            base=ldap.dn.dn2str(self.base), filter=filterstr, attrs=attrlist)
 
         results = self.timedSearch(ldap.dn.dn2str(self.base),
             ldap.SCOPE_SUBTREE, filterstr=filterstr, attrlist=attrlist)
@@ -414,21 +417,20 @@
 
     def getLDAPConnection(self):
         if self.ldap is None:
-            self.log.info("Connecting to LDAP %s" % (repr(self.uri),))
+            self.log.info("Connecting to LDAP {uri}", uri=repr(self.uri))
             self.ldap = self.createLDAPConnection()
-            self.log.info("Connection established to LDAP %s" % (repr(self.uri),))
+            self.log.info("Connection established to LDAP {uri}", uri=repr(self.uri))
             if self.credentials.get("dn", ""):
                 try:
-                    self.log.info("Binding to LDAP %s" %
-                        (repr(self.credentials.get("dn")),))
+                    self.log.info("Binding to LDAP {dn}",
+                        dn=repr(self.credentials.get("dn")))
                     self.ldap.simple_bind_s(self.credentials.get("dn"),
                         self.credentials.get("password"))
-                    self.log.info("Successfully authenticated with LDAP as %s" %
-                        (repr(self.credentials.get("dn")),))
+                    self.log.info("Successfully authenticated with LDAP as {dn}",
+                        dn=repr(self.credentials.get("dn")))
                 except ldap.INVALID_CREDENTIALS:
-                    msg = "Can't bind to LDAP %s: check credentials" % (self.uri,)
-                    self.log.error(msg)
-                    raise DirectoryConfigurationError(msg)
+                    self.log.error("Can't bind to LDAP {uri}: check credentials", uri=self.uri)
+                    raise DirectoryConfigurationError()
         return self.ldap
 
     def createLDAPConnection(self):
@@ -1645,9 +1647,8 @@
                 # Authenticate against PAM (UNTESTED)
 
                 if not pamAvailable:
-                    msg = "PAM module is not installed"
-                    self.log.error(msg)
-                    raise DirectoryConfigurationError(msg)
+                    self.log.error("PAM module is not installed")
+                    raise DirectoryConfigurationError()
 
                 def pam_conv(auth, query_list, userData):
                     return [(credentials.password, 0)]
@@ -1675,15 +1676,14 @@
                     return True
 
                 except ldap.INVALID_CREDENTIALS:
-                    self.log.info("Invalid credentials for %s" %
-                        (repr(self.dn),), system="LdapDirectoryService")
+                    self.log.info("Invalid credentials for {dn}",
+                        dn=repr(self.dn), system="LdapDirectoryService")
                     return False
 
             else:
-                msg = "Unknown Authentication Method '%s'" % (
-                    self.service.authMethod.upper(),)
-                self.log.error(msg)
-                raise DirectoryConfigurationError(msg)
+                self.log.error("Unknown Authentication Method '{method}'",
+                    method=self.service.authMethod.upper())
+                raise DirectoryConfigurationError()
 
         return super(LdapDirectoryRecord, self).verifyCredentials(credentials)
 

Modified: CalendarServer/trunk/txdav/base/datastore/subpostgres.py
===================================================================
--- CalendarServer/trunk/txdav/base/datastore/subpostgres.py	2013-06-13 23:42:13 UTC (rev 11358)
+++ CalendarServer/trunk/txdav/base/datastore/subpostgres.py	2013-06-14 00:19:16 UTC (rev 11359)
@@ -434,7 +434,7 @@
         options.append("-c standard_conforming_strings=on")
         options.extend(self.options)
 
-        log.warn("Requesting postgres start via %s" % (pgCtl,))
+        log.warn("Requesting postgres start via {cmd}", cmd=pgCtl)
         self.reactor.spawnProcess(
             monitor, pgCtl,
             [
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130613/6ead43d9/attachment-0001.html>


More information about the calendarserver-changes mailing list