From ca38ec73403269e5ae359185b7f1c25cc7e6bb85 Mon Sep 17 00:00:00 2001 From: Tim Vieira Date: Thu, 1 Aug 2013 16:01:21 -0400 Subject: [PATCH] added crash summary. --- misc/crash-summary.py | 60 +++++++++++++++++++++++++++++++++ src/Dyna/Backend/Python/repl.py | 2 ++ 2 files changed, 62 insertions(+) create mode 100644 misc/crash-summary.py diff --git a/misc/crash-summary.py b/misc/crash-summary.py new file mode 100644 index 0000000..6e1b7e4 --- /dev/null +++ b/misc/crash-summary.py @@ -0,0 +1,60 @@ +""" +Group similar crashes into a nice colorful summary. + + +$ rsync -a timv-li@login.clsp.jhu.edu:/home/nwf/src/dyna2/crashlogs/. ./. + +Expects data to appear in `crashlogs/` directory + +""" + +import re +from path import path +from collections import defaultdict + +black, red, green, yellow, blue, magenta, cyan, white = \ + map('\033[3%sm%%s\033[0m'.__mod__, range(8)) +bold = '\033[1m%s\033[0m' + + +def data(): + # group data by exception_type / message / traceback + d = [(x, x.lines()) for x in path('crashlogs/').glob('*.log')] + z = defaultdict(lambda: defaultdict(lambda: defaultdict(list))) + for x, ls in d: + y = ls[-1] + t = y.split(':')[0] + tb = '\n'.join(l.strip() for l in ls if '-->' in l) + tb2 = re.sub('\033\[[\d;]+m', '', tb) # remove colors + z[t][y][tb].append((x, tb2, ls)) + return z + + +def show(z, m=3): + """ + m: then number of files to list. + """ + for etype in z: + print bold % yellow % '*'*79 + print etype + for msg in z[etype]: + print ' ', bold % yellow % '-'*77 + print ' ', msg.strip() + for tb, xs in z[etype][msg].items(): + print + for x, _, _ in xs[:m]: + print ' ', red % bold % x + if m is not None and len(xs) > m: + print bold % red % ' %s more...' % (len(xs) - m) + print + for l in tb.split('\n'): + print ' ', l + # show the complete log for first thing +# for l in xs[0][2]: +# print ' ', l.rstrip() + + + print + +if __name__ == '__main__': + show(data(), m=None) diff --git a/src/Dyna/Backend/Python/repl.py b/src/Dyna/Backend/Python/repl.py index 7c30108..37ceac8 100644 --- a/src/Dyna/Backend/Python/repl.py +++ b/src/Dyna/Backend/Python/repl.py @@ -5,6 +5,8 @@ TODO: subscriptions: unsubscribe, only show changes TODO: help should print call signature of loads and post-processors in addition to help. + +TODO: check for errors in query and trace """ import re, os, cmd, readline -- 2.50.1