[CalendarServer-changes] [14463] CalendarServer/trunk

source_changes at macosforge.org source_changes at macosforge.org
Fri Feb 20 11:28:09 PST 2015


Revision: 14463
          http://trac.calendarserver.org//changeset/14463
Author:   sagen at apple.com
Date:     2015-02-20 11:28:09 -0800 (Fri, 20 Feb 2015)
Log Message:
-----------
Command line tools now log to LOGROOT/<name-of-script>.log

Modified Paths:
--------------
    CalendarServer/trunk/calendarserver/tools/cmdline.py
    CalendarServer/trunk/twistedcaldav/stdconfig.py

Modified: CalendarServer/trunk/calendarserver/tools/cmdline.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/cmdline.py	2015-02-20 18:41:05 UTC (rev 14462)
+++ CalendarServer/trunk/calendarserver/tools/cmdline.py	2015-02-20 19:28:09 UTC (rev 14463)
@@ -26,6 +26,8 @@
 from twistedcaldav.config import ConfigurationError
 from twisted.internet.defer import inlineCallbacks, succeed
 from twisted.application.service import Service
+from twisted.python.logfile import LogFile
+from twisted.python.log import FileLogObserver
 
 import sys
 from calendarserver.tap.util import getRootResource
@@ -94,6 +96,15 @@
         if patchConfig is not None:
             patchConfig(config)
 
+        utilityLogFile = LogFile.fromFullPath(
+            config.UtilityLogFile,
+            rotateLength=config.ErrorLogRotateMB * 1024 * 1024,
+            maxRotatedFiles=config.ErrorLogMaxRotatedFiles
+        )
+        utilityLogObserver = FileLogObserver(utilityLogFile)
+        utilityLogObserver.start()
+
+
         checkDirectories(config)
 
         config.ProcessType = "Utility"

Modified: CalendarServer/trunk/twistedcaldav/stdconfig.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/stdconfig.py	2015-02-20 18:41:05 UTC (rev 14462)
+++ CalendarServer/trunk/twistedcaldav/stdconfig.py	2015-02-20 19:28:09 UTC (rev 14463)
@@ -17,9 +17,11 @@
 
 import copy
 import os
+from os.path import basename
 from plistlib import PlistParser  # @UnresolvedImport
 import re
 from socket import getfqdn, gethostbyname
+import sys
 
 from calendarserver.push.util import getAPNTopicFromCertificate
 from twext.python.log import Logger, InvalidLogLevelError, LogLevel
@@ -386,6 +388,7 @@
     "AccessLogFile"  : "access.log", # Apache-style access log
     "ErrorLogFile"   : "error.log", # Server activity log
     "AgentLogFile"   : "agent.log", # Agent activity log
+    "UtilityLogFile"   : "{}.log".format(basename(sys.argv[0])), # Command line utility log
     "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
@@ -1188,6 +1191,7 @@
     ("LogRoot", "AccessLogFile"),
     ("LogRoot", "ErrorLogFile"),
     ("LogRoot", "AgentLogFile"),
+    ("LogRoot", "UtilityLogFile"),
     ("LogRoot", ("Postgres", "LogFile",)),
     ("LogRoot", ("LogDatabase", "StatisticsLogFile",)),
     ("LogRoot", "AccountingLogRoot"),
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20150220/23d64584/attachment.html>


More information about the calendarserver-changes mailing list