@@ -151,9 +151,9 @@ const sfc = {
151
151
POST (` ${ this .run .link } /approve` );
152
152
},
153
153
154
- createLogLine (line , startTime , stepIndex ) {
154
+ createLogLine (line , startTime , stepIndex , {classNames, wrappings} = {} ) {
155
155
const div = document .createElement (' div' );
156
- div .classList .add (' job-log-line' );
156
+ div .classList .add (' job-log-line' , ... classNames );
157
157
div .setAttribute (' id' , ` jobstep-${ stepIndex} -${ line .index } ` );
158
158
div ._jobLogTime = line .timestamp ;
159
159
@@ -179,19 +179,50 @@ const sfc = {
179
179
180
180
const logMessage = document .createElement (' span' );
181
181
logMessage .className = ' log-msg' ;
182
- logMessage .innerHTML = renderAnsi (line .message );
183
- div .append (logTimeStamp);
184
- div .append (logMessage);
185
- div .append (logTimeSeconds);
186
182
183
+ let html = renderAnsi (line .message );
184
+ for (const [before , after ] of wrappings) {
185
+ html = ` ${ before}${ html}${ after} ` ;
186
+ }
187
+ logMessage .innerHTML = html;
188
+
189
+ div .append (logTimeStamp, logMessage, logTimeSeconds);
187
190
return div;
188
191
},
189
192
193
+ getLineHTML ({message, index, timestamp}, startTime , stepIndex ) {
194
+ const wrappings = [];
195
+ const classNames = [];
196
+
197
+ if (message .startsWith (' ::endgroup::' )) {
198
+ classNames .push (' endgroup' );
199
+ } else if (message .startsWith (' ::add-matcher' )) {
200
+ classNames .push (' add-matcher' );
201
+ } else if (message .startsWith (' ::remove-matcher' )) {
202
+ classNames .push (' remove-matcher' );
203
+ } else {
204
+ if (message .startsWith (' ::group::' )) {
205
+ message = message .substring (9 );
206
+ wrappings .push ([' <details><summary>' , ' </summary></details>' ]);
207
+ }
208
+ if (message .startsWith (' ::error::' )) {
209
+ message = message .substring (9 );
210
+ wrappings .push ([' <span class="tw-text-red">' , ' </span>' ]);
211
+ }
212
+ if (message .startsWith (' [command]' )) {
213
+ message = message .substring (9 );
214
+ wrappings .push ([' <span class="tw-text-blue">' , ' </span>' ]);
215
+ }
216
+ }
217
+
218
+ return this .createLogLine ({message, index, timestamp}, startTime, stepIndex, {classNames, wrappings});
219
+ },
220
+
190
221
appendLogs (stepIndex , logLines , startTime ) {
222
+ const el = this .getLogsContainer (stepIndex);
223
+
191
224
for (const line of logLines) {
192
- // TODO: group support: ##[group]GroupTitle , ##[endgroup]
193
- const el = this .getLogsContainer (stepIndex);
194
- el .append (this .createLogLine (line, startTime, stepIndex));
225
+ el .append (this .getLineHTML (line, startTime, stepIndex));
195
226
}
196
227
},
197
228
@@ -789,6 +820,12 @@ export function initRepositoryActionView() {
789
820
scroll- margin- top: 95px ;
790
821
}
791
822
823
+ .job - log- line .add - matcher,
824
+ .job - log- line .remove - matcher,
825
+ .job - log- line .endgroup {
826
+ display: none ! important;
827
+ }
828
+
792
829
/* class names 'log-time-seconds' and 'log-time-stamp' are used in the method toggleTimeDisplay */
793
830
.job - log- line .line - num, .log - time- seconds {
794
831
width: 48px ;
0 commit comments