[Zope-Checkins] CVS: Zope/lib/python/Products/ForensicLogger - ForensicLogger.py:1.1.2.2

Andreas Jung andreas@zope.com
Mon, 22 Oct 2001 17:02:12 -0400


Update of /cvs-repository/Zope/lib/python/Products/ForensicLogger
In directory cvs.zope.org:/tmp/cvs-serv25669/lib/python/Products/ForensicLogger

Modified Files:
      Tag: ajung-forensiclogging
	ForensicLogger.py 
Log Message:


=== Zope/lib/python/Products/ForensicLogger/ForensicLogger.py 1.1.2.1 => 1.1.2.2 ===
 from Globals import DTMLFile
 from Persistence import Persistent
+from OFS.SimpleItem import SimpleItem
 import os, sys, re, threading
 import time
 
     
-class ForensicLogger(threading.Thread):
+class ForensicLogger(SimpleItem):
     """ a forensic logger to log operating specific informations """
 
     meta_type = 'Forensic Logger'
@@ -107,18 +108,14 @@
     )
 
 
-    def run(self,*args,**kw):
-
-        while 1:
-
-            if self._enabled ==0: 
-                time.sleep(5)
-                continue
 
-            print args,kw
+    def __init__(self, id, delay):
 
-            time.sleep(self._delay)
+        self.id     = id
+        self._delay = delay
 
+        self._v_logger = RealLogger(None,RealLogger.run,"ForensicLogger", (self._delay,),{})
+        self._v_logger.start()
 
 
     def enableLogger(self, URL1=None, REQUEST=None, RESPONSE=None):
@@ -161,18 +158,36 @@
 
 manage_addForensicLoggerForm = DTMLFile('dtml/addForensicLogger', globals())
 
-def manage_addForensicLogger(self, id, REQUEST=None, RESPONSE=None, URL3=None):
+
+
+def manage_addForensicLogger(self, id, delay=5,REQUEST=None, RESPONSE=None, URL3=None):
     """Add a ForensicLogger"""
 
+    L = ForensicLogger(id, delay)
+
+    self._setObject(id,L)
+
+    if REQUEST is not None:
+        return self.manage_main(self, REQUEST)
+
 
-    Logger = ForensicLogger(None,
-                ForensicLogger.run,
-                'ForensicLogger',
-                (),
-                {}
-                )
 
-    Logger.start()
+class RealLogger(threading.Thread):
+
+    _delay = 5
+    _enabled = 1
+
+    def run(self,*args,**kw):
+
+
+        while 1:
+
+            if self._enabled ==0: 
+                time.sleep(5)
+                continue
+
+            print args,kw
+
+            time.sleep(self._delay)
 
-    return Logger