gump-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From leosim...@apache.org
Subject svn commit: r161595 - gump/branches/Gump3/pygump/python/gump/plugins/logreporter.py
Date Sat, 16 Apr 2005 18:40:28 GMT
Author: leosimons
Date: Sat Apr 16 11:40:28 2005
New Revision: 161595

URL: http://svn.apache.org/viewcvs?view=rev&rev=161595
Log:
Add a useful debugging plugin.

* pygump/python/gump/plugins/logreporter.py: new plugin that outputs all model logs.

Added:
    gump/branches/Gump3/pygump/python/gump/plugins/logreporter.py
      - copied, changed from r161585, gump/branches/Gump3/pygump/python/gump/plugins/instrumentation.py

Copied: gump/branches/Gump3/pygump/python/gump/plugins/logreporter.py (from r161585, gump/branches/Gump3/pygump/python/gump/plugins/instrumentation.py)
URL: http://svn.apache.org/viewcvs/gump/branches/Gump3/pygump/python/gump/plugins/logreporter.py?view=diff&rev=161595&p1=gump/branches/Gump3/pygump/python/gump/plugins/instrumentation.py&r1=161585&p2=gump/branches/Gump3/pygump/python/gump/plugins/logreporter.py&r2=161595
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/plugins/instrumentation.py (original)
+++ gump/branches/Gump3/pygump/python/gump/plugins/logreporter.py Sat Apr 16 11:40:28 2005
@@ -17,18 +17,30 @@
 __copyright__ = "Copyright (c) 2004-2005 The Apache Software Foundation"
 __license__   = "http://www.apache.org/licenses/LICENSE-2.0"
 
-import platform
-
 from gump.plugins import AbstractPlugin
 
-class TimerPlugin(AbstractPlugin):
-    """Set a date property on each model object as it is visited."""
-    def __init__(self, propertyname, format='%d %b %Y %H:%M:%S'):
-        self.format = format
-        self.propertyname = propertyname
-        
-    def _do_visit(self, object):
-        setattr(object, self.propertyname, self.gettime())
+hr = '------------------------------------------------------------------------'
+
+class LogReporterPlugin(AbstractPlugin):
+    """Outputs all logs set on all log-style model annotations to the log."""
+    def __init__(self, log):
+        self.log = log
+    
+    def initialize(self):
+        self.log.debug(hr)
+        self.log.debug('  Outputting all log data (a lot)...')
+        self.log.debug(hr)
+
+    def _do_visit(self, object, container=None):
+        for attribute in dir(object):
+            if attribute.endswith("_log"):
+                logmsg = getattr(object,attribute)
+                name = getattr(object, "name", "unnamed %s" % type(object))
+                if container:
+                    if hasattr(container, "name"):
+                        name = "%s:%s" % (container.name, name)
+                self.log.debug("---%s.%s----------------------------------:\n%s" % (name,
attribute, logmsg))
+                self.log.debug(hr)
     
     def visit_workspace(self, workspace):
         self._do_visit(workspace)
@@ -38,7 +50,5 @@
     
     def visit_project(self, project):    
         self._do_visit(project)
-
-    def gettime(self):
-        import time
-        return time.strftime(self.format, time.gmtime())
+        for command in project.commands:
+            self._do_visit(command,project)



Mime
View raw message