[CalendarServer-changes] [8872] CalendarServer/trunk/calendarserver/tools/shell

source_changes at macosforge.org source_changes at macosforge.org
Wed Mar 14 16:09:30 PDT 2012


Revision: 8872
          http://trac.macosforge.org/projects/calendarserver/changeset/8872
Author:   wsanchez at apple.com
Date:     2012-03-14 16:09:30 -0700 (Wed, 14 Mar 2012)
Log Message:
-----------
Add log command

Modified Paths:
--------------
    CalendarServer/trunk/calendarserver/tools/shell/cmd.py
    CalendarServer/trunk/calendarserver/tools/shell/terminal.py

Modified: CalendarServer/trunk/calendarserver/tools/shell/cmd.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/shell/cmd.py	2012-03-14 23:09:07 UTC (rev 8871)
+++ CalendarServer/trunk/calendarserver/tools/shell/cmd.py	2012-03-14 23:09:30 UTC (rev 8872)
@@ -425,3 +425,35 @@
         raise NotImplementedError("")
 
     cmd_sql.hidden = "Not implemented."
+
+
+    def cmd_log(self, tokens):
+        """
+        Enable logging.
+
+        usage: log [file]
+        """
+        if hasattr(self, "_logFile"):
+            self.terminal.write("Already logging to file: %s\n" % (self._logFile,))
+            return
+
+        if tokens:
+            fileName = tokens.pop(0)
+        else:
+            fileName = "/tmp/shell.log"
+
+        if tokens:
+            raise UnknownArguments(tokens)
+
+        from twisted.python.log import startLogging
+        try:
+            f = open(fileName, "w")
+        except (IOError, OSError), e:
+            self.terminal.write("Unable to open file %s: %s\n" % (fileName, e))
+            return
+
+        startLogging(f)
+
+        self._logFile = fileName
+
+    cmd_log.hidden = "Debug tool"

Modified: CalendarServer/trunk/calendarserver/tools/shell/terminal.py
===================================================================
--- CalendarServer/trunk/calendarserver/tools/shell/terminal.py	2012-03-14 23:09:07 UTC (rev 8871)
+++ CalendarServer/trunk/calendarserver/tools/shell/terminal.py	2012-03-14 23:09:30 UTC (rev 8872)
@@ -95,12 +95,6 @@
         """
         Start the service.
         """
-        # For debugging
-        if True:
-            from twisted.python.log import startLogging
-            f = open("/tmp/shell.log", "w")
-            startLogging(f)
-
         super(ShellService, self).startService()
 
         # Set up the terminal for interactive action
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20120314/951dbd32/attachment.html>


More information about the calendarserver-changes mailing list