[CalendarServer-changes] [4816] CalendarServer/branches/users/cdaboo/implicit-improvements-4804

source_changes at macosforge.org source_changes at macosforge.org
Thu Dec 3 13:23:50 PST 2009


Revision: 4816
          http://trac.macosforge.org/projects/calendarserver/changeset/4816
Author:   cdaboo at apple.com
Date:     2009-12-03 13:23:50 -0800 (Thu, 03 Dec 2009)
Log Message:
-----------
Tweak the paths used by accounting logging so that we can better discriminate between different
types of logging.

Modified Paths:
--------------
    CalendarServer/branches/users/cdaboo/implicit-improvements-4804/twext/web2/channel/http.py
    CalendarServer/branches/users/cdaboo/implicit-improvements-4804/twistedcaldav/accounting.py

Modified: CalendarServer/branches/users/cdaboo/implicit-improvements-4804/twext/web2/channel/http.py
===================================================================
--- CalendarServer/branches/users/cdaboo/implicit-improvements-4804/twext/web2/channel/http.py	2009-12-01 20:50:11 UTC (rev 4815)
+++ CalendarServer/branches/users/cdaboo/implicit-improvements-4804/twext/web2/channel/http.py	2009-12-03 21:23:50 UTC (rev 4816)
@@ -165,7 +165,7 @@
         if self.logData is not None:
             doneTime = time.time()
             self.logData.response.append("\r\n\r\n<<<< Response complete at: %.3f (elapsed: %.1f ms)\r\n" % (doneTime, 1000 * (doneTime - self.startTime),))
-            accounting.emitAccounting("HTTP", "all", "".join(self.logData.request) + "".join(self.logData.response))
+            accounting.emitAccounting("HTTP", "", "".join(self.logData.request) + "".join(self.logData.response))
 
 HTTPChannel.chanRequestFactory = HTTPLoggingChannelRequest
 

Modified: CalendarServer/branches/users/cdaboo/implicit-improvements-4804/twistedcaldav/accounting.py
===================================================================
--- CalendarServer/branches/users/cdaboo/implicit-improvements-4804/twistedcaldav/accounting.py	2009-12-01 20:50:11 UTC (rev 4815)
+++ CalendarServer/branches/users/cdaboo/implicit-improvements-4804/twistedcaldav/accounting.py	2009-12-03 21:23:50 UTC (rev 4816)
@@ -1,5 +1,5 @@
 ##
-# Copyright (c) 2006-2007 Apple Inc. All rights reserved.
+# Copyright (c) 2006-2009 Apple Inc. All rights reserved.
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -86,42 +86,51 @@
             principal.record.guid
         )
     else:
-        return
+        return None
 
     try:
         #
         # Obtain the accounting log file name
         #
         logRoot = config.AccountingLogRoot
-        logDirectory = os.path.join(
-            logRoot,
-            principalLogPath,
-            category
+        logDirectory = category
+        if principalLogPath:
+            logDirectory = os.path.join(
+                logDirectory,
+                principalLogPath,
+            )
+        logFilename = os.path.join(
+            logDirectory,
+            datetime.datetime.now().isoformat()
         )
-        logFilename = os.path.join(logDirectory, datetime.datetime.now().isoformat())
     
-        if not os.path.isdir(logDirectory):
-            os.makedirs(logDirectory)
+        if not os.path.isdir(os.path.join(logRoot, logDirectory)):
+            os.makedirs(os.path.join(logRoot, logDirectory))
             logFilename = "%s-01" % (logFilename,)
         else:
             index = 1
             while True:
                 path = "%s-%02d" % (logFilename, index)
-                if not os.path.isfile(path):
+                if not os.path.isfile(os.path.join(logRoot, path)):
                     logFilename = path
                     break
                 if index == 1000:
                     log.error("Too many %s accounting files for %s" % (category, principal))
-                    return
+                    return None
+                index += 1
     
         #
         # Now write out the data to the log file
         #
-        logFile = open(logFilename, "a")
+        logFile = open(os.path.join(logRoot, logFilename), "a")
         try:
             logFile.write(data)
         finally:
             logFile.close()
+            
+        return logFilename
+
     except OSError, e:
         # No failures in accounting should propagate out
         log.error("Failed to write accounting data due to: %s" % (str(e),))
+        return None
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20091203/1cacc34b/attachment.html>


More information about the calendarserver-changes mailing list