pretty up the output and add a sample string

Change-Id: I1c37b32e2127ba99b48b5ce3176e605f4e797475
This commit is contained in:
Noel Grandin
2016-06-09 13:38:00 +02:00
parent 258301879b
commit 45913cd580

View File

@@ -14,6 +14,7 @@ process = subprocess.Popen("find workdir -name '*.log' | xargs grep -h 'warn:' |
shell=True, stdout=subprocess.PIPE, universal_newlines=True)
messages = dict() # dict of sourceAndLine->count
sampleOfMessage = dict() # dict of sourceAndLine->string
for line in process.stdout:
line = line.strip()
# a sample line is:
@@ -24,12 +25,13 @@ for line in process.stdout:
messages[sourceAndLine] = messages[sourceAndLine] + 1
else:
messages[sourceAndLine] = 1
sampleOfMessage[sourceAndLine] = tokens[6]
tmplist = list() # set of tuple (count, sourceAndLine)
for key, value in messages.iteritems():
tmplist.append([value,key])
for i in sorted(tmplist, key=lambda v: v[0]):
print i
print( "%6d %s %s" % (i[0], i[1], sampleOfMessage[i[1]]) )