Patchwork [buildbot,6/6] add log tail to failure reports

login
register
mail settings
Submitter Gerd Hoffmann
Date Feb. 1, 2013, 2:02 p.m.
Message ID <1359727345-10477-7-git-send-email-kraxel@redhat.com>
Download mbox | patch
Permalink /patch/217502/
State New
Headers show

Comments

Gerd Hoffmann - Feb. 1, 2013, 2:02 p.m.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 qemu-master.cfg |   27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

Patch

diff --git a/qemu-master.cfg b/qemu-master.cfg
index 04d26bf..b54ceb4 100644
--- a/qemu-master.cfg
+++ b/qemu-master.cfg
@@ -45,6 +45,32 @@  emailAddressesNotify = ["gollub@b1-systems.de", "qemu-devel@nongnu.org", "agraf@
 
 ####### STATUS TARGETS
 
+def logtailMessageFormatter(mode, name, build, results, master_status):
+    result = Results[results]
+    defmsg = mail.defaultMessage(mode, name, build, results, master_status);
+    text = list();
+    text.append(defmsg['body']);
+
+    # get log for last step
+    logs = build.getLogs()
+    for log in reversed(logs):
+        if log.getName() == 'stdio':
+            break
+    content = log.getText().splitlines() # Note: can be VERY LARGE
+    url = "%s/steps/%s/logs/%s" % (master_status.getURLForThing(build),
+                                   log.getStep().getName(),
+                                   log.getName())
+
+    # append log info to standard message
+    text.append("========== log tail ==========")
+    for line in content[-32:]:
+        text.append(unicode(line,'utf8'))
+    text.append("")
+    text.append("========== full log ==========")
+    text.append(url);
+
+    return { 'body' : "\n".join(text), 'type' : 'plain' }
+
 c['status'] = []
 
 from buildbot.status import html
@@ -57,6 +83,7 @@  c['status'].append(
     fromaddr=emailAddressFrom,
     mode='problem', # only send mail about a build which failed when the previous build passed
     extraRecipients=emailAddressesNotify,
+    messageFormatter=logtailMessageFormatter,
     sendToInterestedUsers=False
   )
 )