|
154 | 154 | document.getElementById('filter_error').innerText = error.message;
|
155 | 155 | }
|
156 | 156 | }
|
| 157 | +function detect_ci_logs(logs) |
| 158 | +{ |
| 159 | + nodes = new Set() |
| 160 | + Array.from(logs.matchAll(/[0-9\-T:.Z]+ (lightningd-[0-9]+) /g)).forEach(match => { |
| 161 | + nodes.add(match[1]); |
| 162 | + }); |
| 163 | + var keys = [...nodes]; |
| 164 | + var node = keys.at(0); |
| 165 | + |
| 166 | + if (nodes.size > 1) { |
| 167 | + str = "Continous Integration log with multiple nodes detected.\n\nWhich would you like rendered?\n\nNodes detected:\n" + keys.join("\n"); |
| 168 | + node = prompt(str, keys[0]).trim(); |
| 169 | + } |
| 170 | + |
| 171 | + return node ? new RegExp(`[0-9\-T:.Z]+ ${node} `, "g") : null; |
| 172 | +} |
| 173 | +function detect_pytest_logs(logs) |
| 174 | +{ |
| 175 | + nodes = new Set() |
| 176 | + Array.from(logs.matchAll(/(lightningd-[0-9]+) /g)).forEach(match => { |
| 177 | + nodes.add(match[1]); |
| 178 | + }); |
| 179 | + var keys = [...nodes]; |
| 180 | + var node = keys.at(0); |
| 181 | + |
| 182 | + if (nodes.size > 1) { |
| 183 | + str = "Python Test log with multiple nodes detected.\n\nWhich would you like rendered?\n\nNodes detected:\n" + keys.join("\n"); |
| 184 | + node = prompt(str, keys[0]).trim(); |
| 185 | + } |
| 186 | + |
| 187 | + return node ? new RegExp(`^${node} `, "g") : null; |
| 188 | +} |
| 189 | +function detect_log_prefix(logs) |
| 190 | +{ |
| 191 | + var ci = detect_ci_logs(logs) |
| 192 | + if (ci) |
| 193 | + return ci; |
| 194 | + var pytest = detect_pytest_logs(logs) |
| 195 | + if (pytest) |
| 196 | + return pytest; |
| 197 | + return null; |
| 198 | +} |
157 | 199 | function do_render(logs, area)
|
158 | 200 | {
|
159 | 201 | var d = document;
|
|
168 | 210 | while(sheet.cssRules.length)
|
169 | 211 | sheet.deleteRule(0);
|
170 | 212 |
|
| 213 | + prefix = detect_log_prefix(logs); |
| 214 | + |
171 | 215 | for(line of logs.split("\n")) {
|
172 | 216 | line = line.trim()
|
173 | 217 | if(!line.length)
|
174 | 218 | continue;
|
175 | 219 |
|
| 220 | + /* Detect and eat node prefix. If no prefix match, ignore line */ |
| 221 | + if (prefix) { |
| 222 | + prefix_match = line.match(prefix); |
| 223 | + if(!prefix_match) |
| 224 | + continue; |
| 225 | + line = line.slice(prefix_match[0].length); |
| 226 | + } |
| 227 | + |
176 | 228 | info = parseLogLine(line);
|
177 | 229 |
|
178 | 230 | if(info.msg.startsWith('Server started with public key'))
|
|
0 commit comments