Skip to content

Commit 4d1a2f3

Browse files
committed
contrib: Make log visualizer work with CI
Update the log visualizer to detect logs coming from CI and be able to render them. ChangelogNone
1 parent 79b959b commit 4d1a2f3

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

contrib/log_visualizer.html

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,25 @@
154154
document.getElementById('filter_error').innerText = error.message;
155155
}
156156
}
157+
function node_to_regex(node)
158+
{
159+
return new RegExp(`[0-9\-T:.Z]+ ${node} `, "g");
160+
}
161+
function detect_ci_logs(logs)
162+
{
163+
nodes = new Set()
164+
Array.from(logs.matchAll(/[0-9\-T:.Z]+ (lightningd-[0-9]+) /g)).forEach(match => {
165+
nodes.add(match[1]);
166+
});
167+
if (!nodes.size)
168+
return null;
169+
keys = [...nodes];
170+
if (nodes.size == 1)
171+
return node_to_regex(keys[0])
172+
173+
str = "Continous Integration log with multiple nodes detected.\n\nWhich would you like rendered?\n\nNodes detected:\n" + keys.join("\n");
174+
return node_to_regex(prompt(str, keys[0]).trim());
175+
}
157176
function do_render(logs, area)
158177
{
159178
var d = document;
@@ -168,11 +187,21 @@
168187
while(sheet.cssRules.length)
169188
sheet.deleteRule(0);
170189

190+
prefix = detect_ci_logs(logs);
191+
171192
for(line of logs.split("\n")) {
172193
line = line.trim()
173194
if(!line.length)
174195
continue;
175196

197+
/* Detect and eat node prefix. If no prefix match, ignore line */
198+
if (prefix) {
199+
prefix_match = line.match(prefix);
200+
if(!prefix_match)
201+
continue;
202+
line = line.slice(prefix_match[0].length);
203+
}
204+
176205
info = parseLogLine(line);
177206

178207
if(info.msg.startsWith('Server started with public key'))

0 commit comments

Comments
 (0)