Hello folks,

I'd change slightly the output format of the log handler in
zope.testing.loggingsupport so that one is able to see *what*
went wrong when an exception is logged.  For instance, rather
than getting just:

    zope.app.generations ERROR
      Failed to evolve database to generation 4 for app1

One would get:

    zope.app.generations ERROR
      Failed to evolve database to generation 4 for app1
      Traceback (most recent call last):
      ValueError: 4

Even though this is a simple change, it'll break a few tests in
the Zope 3 tree, and perhaps other projects using the same test
runner (is anyone else using it?).

With this in mind, and considering that I haven't been following
the development as closely as I should, I'd like to check with you
if it's ok to apply the change at this point to the trunk of
zope.testing and update the svn:external link of Zope3 trunk while
fixing the broken tests, or if there's another less disruptive way
of doing it.

The patch is the following one. Notice that in addition to introduce
backtraces, it'll also indent all lines to 2 spaces, rather than just
the first one (so that all of them are identified as pertaining to
the given log message).

Index: loggingsupport.py
--- loggingsupport.py   (revision 69092)
+++ loggingsupport.py   (working copy)
@@ -105,16 +105,16 @@

     def __str__(self):
-        return '\n'.join(
-            [("%s %s\n  %s" %
-              (record.name, record.levelname,
-               '\n'.join([line
-                          for line in record.getMessage().split('\n')
-                          if line.strip()])
-               )
-              )
-              for record in self.records]
-              )
+        lines = []
+        for record in self.records:
+            lines.append("%s %s" % (record.name, record.levelname))
+            for line in record.getMessage().split("\n"):
+                if line.strip():
+                    lines.append("  "+line)
+            if record.exc_info and record.exc_info[0] and record.exc_text:
+                for line in record.exc_text.split("\n"):
+                    lines.append("  "+line)
+        return '\n'.join(lines)

 class InstalledHandler(Handler):

Gustavo Niemeyer
Zope3-dev mailing list
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com

Reply via email to