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

add semantic tags for logs

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