Commit 5e000d58 authored by Leo Iannacone's avatar Leo Iannacone

add semantic tags for logs

parent bf91a99d
......@@ -160,9 +160,10 @@ class DebomaticModule_JSONLogger:
full_path = os.path.join(resultdir, filename)
info = {}
info['size'] = self._get_human_size(os.path.getsize(full_path))
tag = LogParser(full_path).parse()
tag, level = LogParser(full_path).parse()
if tag:
info['tags'] = tag
info['level'] = level
status['files'][filename] = info
self._write_package_json(args, status)
status.pop('files', None)
......@@ -180,16 +181,18 @@ class LogParser():
def parse(self):
if not os.path.isfile(self.file):
return None
result = None
tag = None
# level can be: info, warning, danger
level = "info" # by default
if self.extension == 'lintian':
result = self.parse_lintian()
tag, level = self.parse_lintian()
elif self.extension == 'autopkgtest':
result = self.parse_autopkgtest()
tag, level = self.parse_autopkgtest()
elif self.extension == 'piuparts':
result = self.parse_piuparts()
tag, level = self.parse_piuparts()
elif self.extension == 'blhc':
result = self.parse_blhc()
return result
tag, level = self.parse_blhc()
return tag, level
def parse_lintian(self):
tags = defaultdict(int)
......@@ -197,7 +200,13 @@ class LogParser():
for line in fd:
if len(line) >= 2 and line[0] != 'N' and line[1] == ':':
tags[line[0]] += 1
return self._from_tags_to_result(tags)
tags = self._from_tags_to_result(tags)
level = "info"
if 'E' in tags:
level = "danger"
elif 'W' in tags:
level = "warning"
return tags, level
def parse_autopkgtest(self):
tags = defaultdict(int)
......@@ -218,14 +227,14 @@ class LogParser():
tags[info[0]] += 1
elif found and line == '\n':
break
return self._from_tags_to_result(tags)
return self._from_tags_to_result(tags), 'danger'
def parse_piuparts(self):
with open(self.file, 'r') as fd:
lines = fd.readlines()
if len(lines) == 0 or lines[-1].find('ERROR:') >= 0:
return 'E'
return None
return 'E', 'danger'
return None, None
def parse_blhc(self):
tags = defaultdict(int)
......@@ -236,7 +245,7 @@ class LogParser():
continue
tag = info[0].replace('FLAGS', '')
tags[tag] += 1
return ' '.join(sorted(list(tags.keys())))
return ' '.join(sorted(list(tags.keys()))), 'warning'
def _from_tags_to_result(self, tags):
keys = sorted(list(tags.keys()))
......
......@@ -9,7 +9,7 @@
"serve-static": "*",
"errorhandler ": "*",
"ejs": "1.*",
"socket.io": "1.*",
"socket.io": "1.2.*",
"tail": "*",
"glob": "*",
"extend": "*"
......
......@@ -271,8 +271,9 @@ function Page_Distrubion(socket) {
var html_file = $('<li id="file-' + f.orig_name + '">' +
'<a title="' + f.orig_name + '" href="' +
Utils.from_view_to_hash(tmp) + '">' +
'<span class="tags pull-right"></span>' +
'<span class="name">' + f.name + '</span></a></li>');
'<span class="name">' + f.name + '</span>' +
'<span class="tags"></span>' +
'</a></li>');
html_file.on('click', function () {
files.select(this);
});
......@@ -339,13 +340,20 @@ function Page_Distrubion(socket) {
show: function () {
$('#files').show();
},
set_tags: function (file, tags) {
set_tags: function (file, tags, level) {
// debug(2, "setting tag", file, tags);
$('li[id="file-' + file + '"] .tags').html(tags);
$('li[id="file-' + file + '"] .tags')[0].className = "pull-right tags label label-" + level;
},
set_size: function (file, size) {
// debug(2, "setting size", file, size);
$('[id="file-' + file + '"] a').append('<span class="size">' + size + '</span>');
var $file = $('[id="file-' + file + '"]');
var $tags = $file.find(".tags");
var $size = $('<span class="size pull-right">' + size + '</span>');
if ($tags.length > 0)
$size.insertBefore($tags);
else
$file.append($size);
}
};
......@@ -360,7 +368,7 @@ function Page_Distrubion(socket) {
for (var file in s_files) {
if (s_files.hasOwnProperty(file)) {
if (s_files[file].hasOwnProperty('tags'))
files.set_tags(file, s_files[file].tags);
files.set_tags(file, s_files[file].tags, s_files[file].level);
if (s_files[file].hasOwnProperty('size'))
files.set_size(file, s_files[file].size);
}
......
......@@ -148,7 +148,7 @@ footer .info {
font-size: 70%;
color: rgba(0,0,0,0.25);
float: right;
min-width: 60px;
min-width: 54px;
text-align: right;
display: inline-block;
line-height: 20px;
......@@ -157,7 +157,7 @@ footer .info {
#logs .size {
float: none;
line-height: 0px;
line-height: 12px;
}
#logs .active .size {
......@@ -165,10 +165,15 @@ footer .info {
}
#logs .name {
min-width: 75px;
min-width: 95px;
display: inline-block;
}
#logs .tags {
margin-top: -3px;
padding-top: 3px;
}
#status span {
font-weight: bold;
font-size: small;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment