File tree Expand file tree Collapse file tree 1 file changed +21
-2
lines changed Expand file tree Collapse file tree 1 file changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -129,7 +129,7 @@ async fn process_logs(
129
129
let nonce = Uuid :: new_v4 ( ) . to_hyphenated ( ) . to_string ( ) ;
130
130
131
131
let html = format ! (
132
- r#"<!DOCTYPE html>
132
+ r## "<!DOCTYPE html>
133
133
<html>
134
134
<head>
135
135
<title>{log_uuid} - triagebot</title>
@@ -143,22 +143,41 @@ async fn process_logs(
143
143
color: #CCCCCC;
144
144
white-space: pre;
145
145
}}
146
+ .timestamp {{
147
+ color: unset;
148
+ text-decoration: none;
149
+ }}
150
+ .timestamp:hover {{
151
+ text-decoration: underline;
152
+ }}
146
153
</style>
147
154
<script type="module" nonce="{nonce}">
148
155
import {{ AnsiUp }} from '{ANSI_UP_URL}'
149
156
150
157
var logs = {logs};
151
158
var ansi_up = new AnsiUp();
152
159
160
+ // 1. Tranform the ANSI escape codes to HTML
153
161
var html = ansi_up.ansi_to_html(logs);
154
162
163
+ // 2. Remove UTF-8 useless BOM
164
+ if (html.charCodeAt(0) === 0xFEFF) {{
165
+ html = html.substr(1);
166
+ }}
167
+
168
+ // 3. Add a self-referencial anchor to all timestamps at the start of the lines
169
+ const dateRegex = /^(\d{{4}}-\d{{2}}-\d{{2}}T\d{{2}}:\d{{2}}:\d{{2}}\.\d+Z)/gm;
170
+ html = html.replace(dateRegex, (ts) =>
171
+ `<a id="${{ts}}" href="#${{ts}}" class="timestamp">${{ts}}</a>`
172
+ );
173
+
155
174
var cdiv = document.getElementById("console");
156
175
cdiv.innerHTML = html;
157
176
</script>
158
177
</head>
159
178
<body id="console">
160
179
</body>
161
- </html>"# ,
180
+ </html>"## ,
162
181
) ;
163
182
164
183
tracing:: info!( "gha_logs: serving logs for {log_uuid}" ) ;
You can’t perform that action at this time.
0 commit comments