[CalendarServer-changes] [1762] CalendarServer/trunk/twistedcaldav/admin/logs.py

source_changes at macosforge.org source_changes at macosforge.org
Mon Aug 6 19:31:33 PDT 2007


Revision: 1762
          http://trac.macosforge.org/projects/calendarserver/changeset/1762
Author:   cdaboo at apple.com
Date:     2007-08-06 19:31:32 -0700 (Mon, 06 Aug 2007)

Log Message:
-----------
Catch exceptions when parsing the log file and indicate the line which caused the problem.

Modified Paths:
--------------
    CalendarServer/trunk/twistedcaldav/admin/logs.py

Modified: CalendarServer/trunk/twistedcaldav/admin/logs.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/admin/logs.py	2007-08-06 19:36:07 UTC (rev 1761)
+++ CalendarServer/trunk/twistedcaldav/admin/logs.py	2007-08-07 02:31:32 UTC (rev 1762)
@@ -228,28 +228,32 @@
             print "|" + "----|" * 10 + "\n.",
             last_count = 0
             start_time = time.time()
-            for line_count, line in enumerate(self.logfile.open()):
-                if (line.startswith('Log opened') or 
-                    line.startswith('Log closed')):
-                    continue
-                else:
-                    pline = parseCLFLine(line)
-                    
-                    self.stats.addDate(pline[3])
-                    self.stats.addBytes(int(pline[6]))
-                    self.stats.addRequestStats(pline[4].split(' ')[0], int(pline[5]), int(pline[6]), float(pline[9][:-3]))
-                    self.stats.addTimeOfDayStats(pline[4].split(' ')[0], pline[3][pline[3].find(":") + 1:][:5])
-
-                    if len(pline) > 7:
-                        self.stats.addUserAgent(pline[8])
-
-                    if pline[2] != "-":
-                        self.stats.addActiveUser(pline[2])
+            try:
+                for line_count, line in enumerate(self.logfile.open()):
+                    if (line.startswith('Log opened') or 
+                        line.startswith('Log closed')):
+                        continue
+                    else:
+                        pline = parseCLFLine(line)
                         
-                if (50 * line_count) / total_count > last_count:
-                    sys.stdout.write(".")
-                    sys.stdout.flush()
-                    last_count = (50 * line_count) / total_count
+                        self.stats.addDate(pline[3])
+                        self.stats.addBytes(int(pline[6]))
+                        self.stats.addRequestStats(pline[4].split(' ')[0], int(pline[5]), int(pline[6]), float(pline[9][:-3]))
+                        self.stats.addTimeOfDayStats(pline[4].split(' ')[0], pline[3][pline[3].find(":") + 1:][:5])
+    
+                        if len(pline) > 7:
+                            self.stats.addUserAgent(pline[8])
+    
+                        if pline[2] != "-":
+                            self.stats.addActiveUser(pline[2])
+                            
+                    if (50 * line_count) / total_count > last_count:
+                        sys.stdout.write(".")
+                        sys.stdout.flush()
+                        last_count = (50 * line_count) / total_count
+            except Exception, e:
+                print "Problem at line: %d, %s" % (line_count, e)
+                raise
 
             print ".\nTime taken: %.1f secs\n" % (time.time() - start_time)
 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20070806/f9cc5001/attachment.html


More information about the calendarserver-changes mailing list