[Checkins] SVN: Sandbox/J1m/zeologhack/src/zc/zeologhack/ initial

Jim Fulton jim at zope.com
Tue Sep 1 15:25:44 EDT 2009


Log message for revision 103470:
  initial

Changed:
  A   Sandbox/J1m/zeologhack/src/zc/zeologhack/
  A   Sandbox/J1m/zeologhack/src/zc/zeologhack/__init__.py

-=-
Added: Sandbox/J1m/zeologhack/src/zc/zeologhack/__init__.py
===================================================================
--- Sandbox/J1m/zeologhack/src/zc/zeologhack/__init__.py	                        (rev 0)
+++ Sandbox/J1m/zeologhack/src/zc/zeologhack/__init__.py	2009-09-01 19:25:44 UTC (rev 103470)
@@ -0,0 +1,48 @@
+
+import marshal
+import os
+import time
+import ZEO.zrpc.connection
+
+
+base = '/tmp'
+
+path = None
+
+def log(connection, action=None):
+    """Enable, disable, or get the path of the zeo input log
+    """
+    global path
+
+    if action is None:
+        connection.write("%r\n" % path)
+        return
+
+    if action == 'disable':
+        if path is None:
+            connection.write("Already disabled\n")
+        else:
+            connection.write("disabled %r\n" % path)
+            del ZEO.zrpc.connection.ManagedServerConnection.message_input
+            path = None
+        return
+
+    if action != 'enable':
+        connection.write("Unknown action: %r\n" % action)
+
+    if path:
+        log(connection, 'disable')
+
+    path = os.path.join(base, time.strftime("%y%m%d%H%M%S", time.gmtime()))
+
+    log_file = open(path, 'w')
+    base_message_input = ZEO.zrpc.connection.Connection.message_input
+    dump = marshal.dump
+    timetime = time.time
+
+    def message_input(self, message):
+        dump((id(self), timetime(), message), log_file)
+        base_message_input(self, message)
+
+    ZEO.zrpc.connection.ManagedServerConnection.message_input = message_input
+    connection.write("enabled %r\n" % path)


Property changes on: Sandbox/J1m/zeologhack/src/zc/zeologhack/__init__.py
___________________________________________________________________
Added: svn:keywords
   + Id
Added: svn:eol-style
   + native



More information about the checkins mailing list