[CalendarServer-changes] [15149] CalendarServer/trunk

source_changes at macosforge.org source_changes at macosforge.org
Thu Sep 24 13:19:22 PDT 2015


Revision: 15149
          http://trac.calendarserver.org//changeset/15149
Author:   cdaboo at apple.com
Date:     2015-09-24 13:19:22 -0700 (Thu, 24 Sep 2015)
Log Message:
-----------
Add option to rotate error log on start (useful for debugging).

Modified Paths:
--------------
    CalendarServer/trunk/calendarserver/tap/caldav.py
    CalendarServer/trunk/twistedcaldav/stdconfig.py

Modified: CalendarServer/trunk/calendarserver/tap/caldav.py
===================================================================
--- CalendarServer/trunk/calendarserver/tap/caldav.py	2015-09-22 21:05:44 UTC (rev 15148)
+++ CalendarServer/trunk/calendarserver/tap/caldav.py	2015-09-24 20:19:22 UTC (rev 15149)
@@ -220,7 +220,7 @@
     """ Registers a rotating file logger for error logging, if
         config.ErrorLogEnabled is True. """
 
-    def __init__(self, logEnabled, logPath, logRotateLength, logMaxFiles):
+    def __init__(self, logEnabled, logPath, logRotateLength, logMaxFiles, logRotateOnStart):
         """
         @param logEnabled: Whether to write to a log file
         @type logEnabled: C{boolean}
@@ -233,12 +233,16 @@
 
         @param logMaxFiles: keep at most this many files
         @type logMaxFiles: C{int}
+
+        @param logRotateOnStart: rotate when service starts
+        @type logRotateOnStart: C{bool}
         """
         MultiService.__init__(self)
         self.logEnabled = logEnabled
         self.logPath = logPath
         self.logRotateLength = logRotateLength
         self.logMaxFiles = logMaxFiles
+        self.logRotateOnStart = logRotateOnStart
 
 
     def setServiceParent(self, app):
@@ -251,6 +255,8 @@
                 maxRotatedFiles=self.logMaxFiles
             )
             errorLogObserver = FileLogObserver(errorLogFile).emit
+            if self.logRotateOnStart:
+                errorLogFile.rotate()
 
             # Registering ILogObserver with the Application object
             # gets our observer picked up within AppLogger.start( )
@@ -268,9 +274,12 @@
     def __init__(self, logObserver):
         self.logObserver = logObserver  # accesslog observer
         ErrorLoggingMultiService.__init__(
-            self, config.ErrorLogEnabled,
-            config.ErrorLogFile, config.ErrorLogRotateMB * 1024 * 1024,
-            config.ErrorLogMaxRotatedFiles
+            self,
+            config.ErrorLogEnabled,
+            config.ErrorLogFile,
+            config.ErrorLogRotateMB * 1024 * 1024,
+            config.ErrorLogMaxRotatedFiles,
+            config.ErrorLogRotateOnStart,
         )
 
 
@@ -1464,7 +1473,8 @@
             config.ErrorLogEnabled,
             config.AgentLogFile,
             config.ErrorLogRotateMB * 1024 * 1024,
-            config.ErrorLogMaxRotatedFiles
+            config.ErrorLogMaxRotatedFiles,
+            config.ErrorLogRotateOnStart,
         )
         svc.setServiceParent(agentLoggingService)
         return agentLoggingService
@@ -1642,7 +1652,8 @@
             config.ErrorLogEnabled,
             config.ErrorLogFile,
             config.ErrorLogRotateMB * 1024 * 1024,
-            config.ErrorLogMaxRotatedFiles
+            config.ErrorLogMaxRotatedFiles,
+            config.ErrorLogRotateOnStart,
         )
 
         # Perform early pre-flight checks.  If this returns True, continue on.

Modified: CalendarServer/trunk/twistedcaldav/stdconfig.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/stdconfig.py	2015-09-22 21:05:44 UTC (rev 15148)
+++ CalendarServer/trunk/twistedcaldav/stdconfig.py	2015-09-24 20:19:22 UTC (rev 15149)
@@ -422,6 +422,7 @@
     "ErrorLogEnabled"   : True, # True = use log file, False = stdout
     "ErrorLogRotateMB"  : 10, # Rotate error log after so many megabytes
     "ErrorLogMaxRotatedFiles"  : 5, # Retain this many error log files
+    "ErrorLogRotateOnStart" : False, # Rotate error log when service starts
     "PIDFile"        : "caldavd.pid",
     "RotateAccessLog"   : False,
     "EnableExtendedAccessLog": True,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20150924/600184ad/attachment.html>


More information about the calendarserver-changes mailing list