File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change 154
154
document . getElementById ( 'filter_error' ) . innerText = error . message ;
155
155
}
156
156
}
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 ] + ( l i g h t n i n g d - [ 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
+ }
157
176
function do_render ( logs , area )
158
177
{
159
178
var d = document ;
168
187
while ( sheet . cssRules . length )
169
188
sheet . deleteRule ( 0 ) ;
170
189
190
+ prefix = detect_ci_logs ( logs ) ;
191
+
171
192
for ( line of logs . split ( "\n" ) ) {
172
193
line = line . trim ( )
173
194
if ( ! line . length )
174
195
continue ;
175
196
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
+
176
205
info = parseLogLine ( line ) ;
177
206
178
207
if ( info . msg . startsWith ( 'Server started with public key' ) )
You can’t perform that action at this time.
0 commit comments