codecraftai-integration-runtime 1.3.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ccai/integrationruntime/__init__.py +27 -0
- ccai/integrationruntime/entrypoints.py +59 -0
- ccai/integrationruntime/initialize.py +100 -0
- ccai/integrationruntime/integratedtestjob.py +100 -0
- ccai/integrationruntime/integrationruntimedefaulttypefactory.py +51 -0
- ccai/integrationruntime/py.typed +0 -0
- ccai/integrationruntime/results/__init__.py +13 -0
- ccai/integrationruntime/results/concentrators/__init__.py +13 -0
- ccai/integrationruntime/results/concentrators/progressconcentratorservice.py +526 -0
- ccai/integrationruntime/results/recorders/__init__.py +22 -0
- ccai/integrationruntime/results/recorders/integrationjsonresultrecorder.py +126 -0
- ccai/integrationruntime/results/recorders/streamingresultrecorder.py +271 -0
- ccai/integrationruntime/results/streaming/__init__.py +25 -0
- ccai/integrationruntime/results/streaming/resultstreamer.py +581 -0
- ccai/integrationruntime/runtimeoutputcontext.py +68 -0
- ccai/integrationruntime/runtimerunmetadata.py +165 -0
- ccai/integrationruntime/templates/v2/static/images/test-report-banner-background-image.png +0 -0
- ccai/integrationruntime/templates/v2/static/javascript/d3.v7.js +20625 -0
- ccai/integrationruntime/templates/v2/static/javascript/icon-components.js +510 -0
- ccai/integrationruntime/templates/v2/static/javascript/mojo-components.js +1417 -0
- ccai/integrationruntime/templates/v2/static/javascript/prism.js +1789 -0
- ccai/integrationruntime/templates/v2/static/javascript/testsummary-accessibility.js +704 -0
- ccai/integrationruntime/templates/v2/static/javascript/testsummary-comparison.js +1287 -0
- ccai/integrationruntime/templates/v2/static/javascript/testsummary-components.js +3499 -0
- ccai/integrationruntime/templates/v2/static/javascript/testsummary-helpers.js +426 -0
- ccai/integrationruntime/templates/v2/static/javascript/testsummary-responsive.js +493 -0
- ccai/integrationruntime/templates/v2/static/javascript/testsummary.js +1128 -0
- ccai/integrationruntime/templates/v2/static/javascript/webcomponent-helpers.js +112 -0
- ccai/integrationruntime/templates/v2/static/styles/branding-theme.css +144 -0
- ccai/integrationruntime/templates/v2/static/styles/icon-styles.css +9 -0
- ccai/integrationruntime/templates/v2/static/styles/mojo-components.css +384 -0
- ccai/integrationruntime/templates/v2/static/styles/prism.css +143 -0
- ccai/integrationruntime/templates/v2/static/styles/tabs-responsive.css +186 -0
- ccai/integrationruntime/templates/v2/static/styles/testsummary-accessibility.css +413 -0
- ccai/integrationruntime/templates/v2/static/styles/testsummary-comparison.css +746 -0
- ccai/integrationruntime/templates/v2/static/styles/testsummary-responsive.css +679 -0
- ccai/integrationruntime/templates/v2/static/styles/testsummary.css +1631 -0
- ccai/integrationruntime/templates/v2/tabs/tab-data.html +870 -0
- ccai/integrationruntime/templates/v2/tabs/tab-images.html +110 -0
- ccai/integrationruntime/templates/v2/tabs/tab-logs.html +594 -0
- ccai/integrationruntime/templates/v2/tabs/tab-sounds.html +112 -0
- ccai/integrationruntime/templates/v2/tabs/tab-timeseries.html +368 -0
- ccai/integrationruntime/templates/v2/tabs/tab-videos.html +372 -0
- ccai/integrationruntime/templates/v2/testsummary.html +81 -0
- codecraftai_integration_runtime-1.3.0.dist-info/METADATA +73 -0
- codecraftai_integration_runtime-1.3.0.dist-info/RECORD +48 -0
- codecraftai_integration_runtime-1.3.0.dist-info/WHEEL +4 -0
- codecraftai_integration_runtime-1.3.0.dist-info/licenses/LICENSE.md +204 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<!--
|
|
4
|
+
__author__ = "Myron Walker"
|
|
5
|
+
__copyright__ = "Copyright 2025, Code Craft AI LLC"
|
|
6
|
+
-->
|
|
7
|
+
<head>
|
|
8
|
+
<title>Images</title>
|
|
9
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, user-scalable=yes">
|
|
10
|
+
|
|
11
|
+
<script type="text/javascript" src="/static/v2/javascript/testsummary-helpers.js"></script>
|
|
12
|
+
<link rel="stylesheet" href="/static/v2/styles/tabs-responsive.css" ></link>
|
|
13
|
+
|
|
14
|
+
<style>
|
|
15
|
+
|
|
16
|
+
.page-style {
|
|
17
|
+
margin: 0px;
|
|
18
|
+
padding: 10px;
|
|
19
|
+
box-sizing: border-box;
|
|
20
|
+
width: 100%;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.flex-container {
|
|
24
|
+
display: flex;
|
|
25
|
+
flex-wrap: wrap;
|
|
26
|
+
width: auto;
|
|
27
|
+
height: auto;
|
|
28
|
+
gap: 15px;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.item-container {
|
|
32
|
+
display: flex;
|
|
33
|
+
flex-direction: column;
|
|
34
|
+
max-width: 100%;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.item-label {
|
|
38
|
+
width: 100%;
|
|
39
|
+
height: 30px;
|
|
40
|
+
justify-content: center;
|
|
41
|
+
font-weight: bold;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.item-content {
|
|
45
|
+
width: 100%;
|
|
46
|
+
height: auto;
|
|
47
|
+
max-width: 100%;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.item-container img {
|
|
51
|
+
max-width: 100%;
|
|
52
|
+
height: auto;
|
|
53
|
+
}
|
|
54
|
+
</style>
|
|
55
|
+
|
|
56
|
+
<script type="text/javascript">
|
|
57
|
+
var g_items_ext_list = ["png", "jpg"]
|
|
58
|
+
var g_items = [];
|
|
59
|
+
|
|
60
|
+
async function refresh_items() {
|
|
61
|
+
var itemsContainerEl = document.getElementById('flex-container');
|
|
62
|
+
|
|
63
|
+
for (var findex in g_items) {
|
|
64
|
+
var filename = g_items[findex];
|
|
65
|
+
|
|
66
|
+
g_items.push(filename);
|
|
67
|
+
|
|
68
|
+
var containerEl = document.createElement("div");
|
|
69
|
+
containerEl.classList.add("item-container");
|
|
70
|
+
|
|
71
|
+
var headerEl = document.createElement('span');
|
|
72
|
+
headerEl.style.width = "100%";
|
|
73
|
+
headerEl.innerHTML = filename;
|
|
74
|
+
|
|
75
|
+
containerEl.appendChild(headerEl);
|
|
76
|
+
|
|
77
|
+
var contentEl = document.createElement('img');
|
|
78
|
+
contentEl.setAttribute("src", filename);
|
|
79
|
+
|
|
80
|
+
containerEl.appendChild(contentEl);
|
|
81
|
+
|
|
82
|
+
itemsContainerEl.appendChild(containerEl);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
async function refresh_page() {
|
|
87
|
+
fetch_items(g_items_ext_list).then((items) => {
|
|
88
|
+
g_items = items;
|
|
89
|
+
|
|
90
|
+
refresh_items();
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
refresh_page().then(function() {
|
|
95
|
+
console.log("Page loaded");
|
|
96
|
+
}, function(err) {
|
|
97
|
+
console.log("ERROR:\n" + err);
|
|
98
|
+
console.log(err.stack)
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
</script>
|
|
102
|
+
</head>
|
|
103
|
+
|
|
104
|
+
<body class="page-style">
|
|
105
|
+
<h3>Images</h3>
|
|
106
|
+
<div id='flex-container' class='flex-container'>
|
|
107
|
+
</div>
|
|
108
|
+
</body>
|
|
109
|
+
|
|
110
|
+
</html>
|
|
@@ -0,0 +1,594 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<!--
|
|
4
|
+
__author__ = "Myron Walker"
|
|
5
|
+
__copyright__ = "Copyright 2025, Code Craft AI LLC"
|
|
6
|
+
|
|
7
|
+
Log File Viewer Tab
|
|
8
|
+
|
|
9
|
+
This tab page displays log files with search functionality,
|
|
10
|
+
line numbers, and log level highlighting.
|
|
11
|
+
-->
|
|
12
|
+
<head>
|
|
13
|
+
<title>Log Files</title>
|
|
14
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, user-scalable=yes">
|
|
15
|
+
|
|
16
|
+
<script type="text/javascript" src="/static/v2/javascript/testsummary-helpers.js"></script>
|
|
17
|
+
<link rel="stylesheet" href="/static/v2/styles/tabs-responsive.css" ></link>
|
|
18
|
+
|
|
19
|
+
<style>
|
|
20
|
+
* {
|
|
21
|
+
box-sizing: border-box;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
body {
|
|
25
|
+
margin: 0;
|
|
26
|
+
padding: 10px;
|
|
27
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
|
|
28
|
+
font-size: 14px;
|
|
29
|
+
line-height: 1.5;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.page-header {
|
|
33
|
+
display: flex;
|
|
34
|
+
flex-wrap: wrap;
|
|
35
|
+
justify-content: space-between;
|
|
36
|
+
align-items: center;
|
|
37
|
+
margin-bottom: 15px;
|
|
38
|
+
padding-bottom: 10px;
|
|
39
|
+
border-bottom: 1px solid #ddd;
|
|
40
|
+
gap: 10px;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.page-title {
|
|
44
|
+
margin: 0;
|
|
45
|
+
font-size: 1.5em;
|
|
46
|
+
color: #333;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.search-container {
|
|
50
|
+
display: flex;
|
|
51
|
+
flex-wrap: wrap;
|
|
52
|
+
gap: 10px;
|
|
53
|
+
align-items: center;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.search-input {
|
|
57
|
+
padding: 8px 12px;
|
|
58
|
+
border: 1px solid #ccc;
|
|
59
|
+
border-radius: 4px;
|
|
60
|
+
font-size: 14px;
|
|
61
|
+
width: 250px;
|
|
62
|
+
max-width: 100%;
|
|
63
|
+
min-height: 44px;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.search-input:focus {
|
|
67
|
+
outline: none;
|
|
68
|
+
border-color: #2E5A8F;
|
|
69
|
+
box-shadow: 0 0 3px rgba(46, 90, 143, 0.3);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.match-count {
|
|
73
|
+
font-size: 12px;
|
|
74
|
+
color: #666;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.log-container {
|
|
78
|
+
margin-bottom: 20px;
|
|
79
|
+
border: 1px solid #ddd;
|
|
80
|
+
border-radius: 4px;
|
|
81
|
+
overflow: hidden;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.log-header {
|
|
85
|
+
display: flex;
|
|
86
|
+
flex-wrap: wrap;
|
|
87
|
+
justify-content: space-between;
|
|
88
|
+
align-items: center;
|
|
89
|
+
padding: 10px 15px;
|
|
90
|
+
background-color: #f5f5f5;
|
|
91
|
+
border-bottom: 1px solid #ddd;
|
|
92
|
+
cursor: pointer;
|
|
93
|
+
gap: 10px;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.log-header:hover {
|
|
97
|
+
background-color: #eee;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.log-filename {
|
|
101
|
+
font-weight: bold;
|
|
102
|
+
color: #333;
|
|
103
|
+
word-break: break-all;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.log-meta {
|
|
107
|
+
font-size: 12px;
|
|
108
|
+
color: #666;
|
|
109
|
+
margin-left: 10px;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.log-header-left {
|
|
113
|
+
display: flex;
|
|
114
|
+
flex-wrap: wrap;
|
|
115
|
+
align-items: center;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.log-header-right {
|
|
119
|
+
display: flex;
|
|
120
|
+
flex-wrap: wrap;
|
|
121
|
+
align-items: center;
|
|
122
|
+
gap: 10px;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.log-toggle {
|
|
126
|
+
font-size: 18px;
|
|
127
|
+
color: #666;
|
|
128
|
+
user-select: none;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.log-download {
|
|
132
|
+
padding: 8px 12px;
|
|
133
|
+
border: 1px solid #ccc;
|
|
134
|
+
border-radius: 4px;
|
|
135
|
+
background-color: #fff;
|
|
136
|
+
cursor: pointer;
|
|
137
|
+
font-size: 12px;
|
|
138
|
+
color: #333;
|
|
139
|
+
min-height: 44px;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.log-download:hover {
|
|
143
|
+
background-color: #e9e9e9;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.log-content {
|
|
147
|
+
max-height: 500px;
|
|
148
|
+
overflow: auto;
|
|
149
|
+
background-color: #1e1e1e;
|
|
150
|
+
color: #d4d4d4;
|
|
151
|
+
-webkit-overflow-scrolling: touch;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.log-content.collapsed {
|
|
155
|
+
display: none;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
.log-content pre {
|
|
159
|
+
margin: 0;
|
|
160
|
+
padding: 15px;
|
|
161
|
+
font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
|
|
162
|
+
font-size: 13px;
|
|
163
|
+
line-height: 1.4;
|
|
164
|
+
white-space: pre-wrap;
|
|
165
|
+
word-wrap: break-word;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.log-line {
|
|
169
|
+
display: block;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
.log-line:hover {
|
|
173
|
+
background-color: #2d2d2d;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.log-line-number {
|
|
177
|
+
display: inline-block;
|
|
178
|
+
width: 50px;
|
|
179
|
+
color: #858585;
|
|
180
|
+
text-align: right;
|
|
181
|
+
padding-right: 15px;
|
|
182
|
+
user-select: none;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
.log-line-content {
|
|
186
|
+
color: #d4d4d4;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/* Log level highlighting */
|
|
190
|
+
.log-level-error {
|
|
191
|
+
color: #f48771;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
.log-level-warn {
|
|
195
|
+
color: #cca700;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
.log-level-info {
|
|
199
|
+
color: #3dc9b0;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
.log-level-debug {
|
|
203
|
+
color: #9cdcfe;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
.highlight {
|
|
207
|
+
background-color: #613214;
|
|
208
|
+
color: #fff;
|
|
209
|
+
padding: 1px 2px;
|
|
210
|
+
border-radius: 2px;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
.no-logs {
|
|
214
|
+
padding: 40px;
|
|
215
|
+
text-align: center;
|
|
216
|
+
color: #666;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
.loading {
|
|
220
|
+
padding: 40px;
|
|
221
|
+
text-align: center;
|
|
222
|
+
color: #666;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
.filter-buttons {
|
|
226
|
+
display: flex;
|
|
227
|
+
flex-wrap: wrap;
|
|
228
|
+
gap: 5px;
|
|
229
|
+
margin-left: 10px;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
.filter-btn {
|
|
233
|
+
padding: 8px 12px;
|
|
234
|
+
border: 1px solid #ccc;
|
|
235
|
+
border-radius: 4px;
|
|
236
|
+
background-color: #fff;
|
|
237
|
+
cursor: pointer;
|
|
238
|
+
font-size: 11px;
|
|
239
|
+
min-height: 44px;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
.filter-btn:hover {
|
|
243
|
+
background-color: #e9e9e9;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
.filter-btn.active {
|
|
247
|
+
background-color: #2E5A8F;
|
|
248
|
+
color: #fff;
|
|
249
|
+
border-color: #2E5A8F;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
.filter-btn.error { border-left: 3px solid #f48771; }
|
|
253
|
+
.filter-btn.warn { border-left: 3px solid #cca700; }
|
|
254
|
+
.filter-btn.info { border-left: 3px solid #3dc9b0; }
|
|
255
|
+
.filter-btn.debug { border-left: 3px solid #9cdcfe; }
|
|
256
|
+
|
|
257
|
+
/* Responsive adjustments */
|
|
258
|
+
@media (max-width: 768px) {
|
|
259
|
+
.filter-buttons {
|
|
260
|
+
margin-left: 0;
|
|
261
|
+
width: 100%;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
.search-input {
|
|
265
|
+
width: 100%;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
.log-line-number {
|
|
269
|
+
width: 40px;
|
|
270
|
+
padding-right: 10px;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
@media (max-width: 480px) {
|
|
275
|
+
.log-content pre {
|
|
276
|
+
font-size: 11px;
|
|
277
|
+
padding: 10px;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
.log-line-number {
|
|
281
|
+
width: 35px;
|
|
282
|
+
font-size: 10px;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
</style>
|
|
286
|
+
|
|
287
|
+
<script type="text/javascript">
|
|
288
|
+
// Supported log file extensions
|
|
289
|
+
const LOG_EXTENSIONS = ["log", "txt", "out"];
|
|
290
|
+
|
|
291
|
+
// Global state
|
|
292
|
+
let g_logs = [];
|
|
293
|
+
let g_searchTerm = "";
|
|
294
|
+
let g_activeFilters = new Set();
|
|
295
|
+
let g_matchCount = 0;
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* Fetch log files from the catalog
|
|
299
|
+
*/
|
|
300
|
+
async function fetch_log_files() {
|
|
301
|
+
try {
|
|
302
|
+
const catalog = await fetch_json("catalog.json");
|
|
303
|
+
if (!catalog || !catalog.files) {
|
|
304
|
+
return [];
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
return catalog.files.filter(filename => {
|
|
308
|
+
const ext = filename.split('.').pop().toLowerCase();
|
|
309
|
+
return LOG_EXTENSIONS.includes(ext);
|
|
310
|
+
});
|
|
311
|
+
} catch (err) {
|
|
312
|
+
console.error("Failed to load catalog:", err);
|
|
313
|
+
return [];
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Fetch the content of a log file
|
|
319
|
+
*/
|
|
320
|
+
async function fetch_log_content(filename) {
|
|
321
|
+
try {
|
|
322
|
+
const response = await fetch(filename);
|
|
323
|
+
if (!response.ok) {
|
|
324
|
+
throw new Error(`HTTP ${response.status}`);
|
|
325
|
+
}
|
|
326
|
+
return await response.text();
|
|
327
|
+
} catch (err) {
|
|
328
|
+
console.error(`Failed to load ${filename}:`, err);
|
|
329
|
+
return `[Error loading file: ${err.message}]`;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* Determine the log level from a line of text
|
|
335
|
+
*/
|
|
336
|
+
function getLogLevel(line) {
|
|
337
|
+
const upperLine = line.toUpperCase();
|
|
338
|
+
if (upperLine.includes("ERROR") || upperLine.includes("FATAL") || upperLine.includes("CRITICAL") || upperLine.includes("EXCEPTION")) {
|
|
339
|
+
return "error";
|
|
340
|
+
}
|
|
341
|
+
if (upperLine.includes("WARN") || upperLine.includes("WARNING")) {
|
|
342
|
+
return "warn";
|
|
343
|
+
}
|
|
344
|
+
if (upperLine.includes("INFO")) {
|
|
345
|
+
return "info";
|
|
346
|
+
}
|
|
347
|
+
if (upperLine.includes("DEBUG") || upperLine.includes("TRACE")) {
|
|
348
|
+
return "debug";
|
|
349
|
+
}
|
|
350
|
+
return "";
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* Escape special regex characters
|
|
355
|
+
*/
|
|
356
|
+
function escapeRegex(string) {
|
|
357
|
+
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* Format log content with line numbers and syntax highlighting
|
|
362
|
+
*/
|
|
363
|
+
function formatLogContent(content, searchTerm, filters) {
|
|
364
|
+
const lines = content.split('\n');
|
|
365
|
+
let html = '';
|
|
366
|
+
let matchCount = 0;
|
|
367
|
+
|
|
368
|
+
lines.forEach((line, index) => {
|
|
369
|
+
const lineNum = index + 1;
|
|
370
|
+
const logLevel = getLogLevel(line);
|
|
371
|
+
|
|
372
|
+
// Apply filter if active
|
|
373
|
+
if (filters.size > 0 && logLevel && !filters.has(logLevel)) {
|
|
374
|
+
return; // Skip this line
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
const levelClass = logLevel ? `log-level-${logLevel}` : '';
|
|
378
|
+
|
|
379
|
+
// Escape HTML entities
|
|
380
|
+
let escapedLine = line
|
|
381
|
+
.replace(/&/g, '&')
|
|
382
|
+
.replace(/</g, '<')
|
|
383
|
+
.replace(/>/g, '>');
|
|
384
|
+
|
|
385
|
+
// Highlight search term if present
|
|
386
|
+
if (searchTerm && searchTerm.length > 0) {
|
|
387
|
+
const regex = new RegExp(`(${escapeRegex(searchTerm)})`, 'gi');
|
|
388
|
+
const matches = escapedLine.match(regex);
|
|
389
|
+
if (matches) {
|
|
390
|
+
matchCount += matches.length;
|
|
391
|
+
}
|
|
392
|
+
escapedLine = escapedLine.replace(regex, '<span class="highlight">$1</span>');
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
html += `<span class="log-line">`;
|
|
396
|
+
html += `<span class="log-line-number">${lineNum}</span>`;
|
|
397
|
+
html += `<span class="log-line-content ${levelClass}">${escapedLine}</span>`;
|
|
398
|
+
html += `</span>\n`;
|
|
399
|
+
});
|
|
400
|
+
|
|
401
|
+
return { html, matchCount };
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* Toggle log content visibility
|
|
406
|
+
*/
|
|
407
|
+
function toggleLog(logId) {
|
|
408
|
+
const contentEl = document.getElementById(`log-content-${logId}`);
|
|
409
|
+
const toggleEl = document.getElementById(`log-toggle-${logId}`);
|
|
410
|
+
|
|
411
|
+
if (contentEl.classList.contains('collapsed')) {
|
|
412
|
+
contentEl.classList.remove('collapsed');
|
|
413
|
+
toggleEl.textContent = '−';
|
|
414
|
+
} else {
|
|
415
|
+
contentEl.classList.add('collapsed');
|
|
416
|
+
toggleEl.textContent = '+';
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* Download a log file
|
|
422
|
+
*/
|
|
423
|
+
function downloadLog(filename, event) {
|
|
424
|
+
event.stopPropagation();
|
|
425
|
+
const link = document.createElement('a');
|
|
426
|
+
link.href = filename;
|
|
427
|
+
link.download = filename;
|
|
428
|
+
document.body.appendChild(link);
|
|
429
|
+
link.click();
|
|
430
|
+
document.body.removeChild(link);
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
/**
|
|
434
|
+
* Create a log container element
|
|
435
|
+
*/
|
|
436
|
+
function createLogContainer(filename, content, index) {
|
|
437
|
+
const container = document.createElement('div');
|
|
438
|
+
container.className = 'log-container';
|
|
439
|
+
container.id = `log-${index}`;
|
|
440
|
+
|
|
441
|
+
const lineCount = content.split('\n').length;
|
|
442
|
+
const fileSize = new Blob([content]).size;
|
|
443
|
+
const sizeStr = fileSize > 1024
|
|
444
|
+
? `${(fileSize / 1024).toFixed(1)} KB`
|
|
445
|
+
: `${fileSize} bytes`;
|
|
446
|
+
|
|
447
|
+
const { html: formattedContent } = formatLogContent(content, g_searchTerm, g_activeFilters);
|
|
448
|
+
|
|
449
|
+
container.innerHTML = `
|
|
450
|
+
<div class="log-header" onclick="toggleLog(${index})">
|
|
451
|
+
<div class="log-header-left">
|
|
452
|
+
<span class="log-filename">${filename}</span>
|
|
453
|
+
<span class="log-meta">${lineCount} lines, ${sizeStr}</span>
|
|
454
|
+
</div>
|
|
455
|
+
<div class="log-header-right">
|
|
456
|
+
<button class="log-download" onclick="downloadLog('${filename}', event)" title="Download">⬇ Download</button>
|
|
457
|
+
<span class="log-toggle" id="log-toggle-${index}">−</span>
|
|
458
|
+
</div>
|
|
459
|
+
</div>
|
|
460
|
+
<div class="log-content" id="log-content-${index}">
|
|
461
|
+
<pre>${formattedContent}</pre>
|
|
462
|
+
</div>
|
|
463
|
+
`;
|
|
464
|
+
|
|
465
|
+
return container;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
/**
|
|
469
|
+
* Update match count display
|
|
470
|
+
*/
|
|
471
|
+
function updateMatchCount() {
|
|
472
|
+
const matchCountEl = document.getElementById('match-count');
|
|
473
|
+
if (g_searchTerm && g_matchCount > 0) {
|
|
474
|
+
matchCountEl.textContent = `${g_matchCount} matches`;
|
|
475
|
+
matchCountEl.style.display = 'inline';
|
|
476
|
+
} else if (g_searchTerm && g_matchCount === 0) {
|
|
477
|
+
matchCountEl.textContent = 'No matches';
|
|
478
|
+
matchCountEl.style.display = 'inline';
|
|
479
|
+
} else {
|
|
480
|
+
matchCountEl.style.display = 'none';
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
/**
|
|
485
|
+
* Re-render all log content
|
|
486
|
+
*/
|
|
487
|
+
function rerenderLogs() {
|
|
488
|
+
g_matchCount = 0;
|
|
489
|
+
|
|
490
|
+
g_logs.forEach((log, index) => {
|
|
491
|
+
const contentEl = document.getElementById(`log-content-${index}`);
|
|
492
|
+
if (contentEl) {
|
|
493
|
+
const preEl = contentEl.querySelector('pre');
|
|
494
|
+
if (preEl) {
|
|
495
|
+
const { html, matchCount } = formatLogContent(log.content, g_searchTerm, g_activeFilters);
|
|
496
|
+
preEl.innerHTML = html;
|
|
497
|
+
g_matchCount += matchCount;
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
});
|
|
501
|
+
|
|
502
|
+
updateMatchCount();
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
/**
|
|
506
|
+
* Handle search input
|
|
507
|
+
*/
|
|
508
|
+
function handleSearch(event) {
|
|
509
|
+
g_searchTerm = event.target.value;
|
|
510
|
+
rerenderLogs();
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
/**
|
|
514
|
+
* Toggle filter
|
|
515
|
+
*/
|
|
516
|
+
function toggleFilter(level) {
|
|
517
|
+
const btn = document.querySelector(`.filter-btn.${level}`);
|
|
518
|
+
|
|
519
|
+
if (g_activeFilters.has(level)) {
|
|
520
|
+
g_activeFilters.delete(level);
|
|
521
|
+
btn.classList.remove('active');
|
|
522
|
+
} else {
|
|
523
|
+
g_activeFilters.add(level);
|
|
524
|
+
btn.classList.add('active');
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
rerenderLogs();
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
/**
|
|
531
|
+
* Refresh the log display
|
|
532
|
+
*/
|
|
533
|
+
async function refreshLogs() {
|
|
534
|
+
const containerEl = document.getElementById('logs-container');
|
|
535
|
+
containerEl.innerHTML = '<div class="loading">Loading log files...</div>';
|
|
536
|
+
|
|
537
|
+
const logFiles = await fetch_log_files();
|
|
538
|
+
|
|
539
|
+
if (logFiles.length === 0) {
|
|
540
|
+
containerEl.innerHTML = '<div class="no-logs">No log files found in this directory.</div>';
|
|
541
|
+
return;
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
containerEl.innerHTML = '';
|
|
545
|
+
g_logs = [];
|
|
546
|
+
|
|
547
|
+
for (let i = 0; i < logFiles.length; i++) {
|
|
548
|
+
const filename = logFiles[i];
|
|
549
|
+
const content = await fetch_log_content(filename);
|
|
550
|
+
|
|
551
|
+
g_logs.push({ filename, content });
|
|
552
|
+
|
|
553
|
+
const logEl = createLogContainer(filename, content, i);
|
|
554
|
+
containerEl.appendChild(logEl);
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
/**
|
|
559
|
+
* Initialize the page
|
|
560
|
+
*/
|
|
561
|
+
async function initPage() {
|
|
562
|
+
await refreshLogs();
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
// Start loading when the page is ready
|
|
566
|
+
document.addEventListener('DOMContentLoaded', initPage);
|
|
567
|
+
</script>
|
|
568
|
+
</head>
|
|
569
|
+
|
|
570
|
+
<body>
|
|
571
|
+
<div class="page-header">
|
|
572
|
+
<h3 class="page-title">Log Files</h3>
|
|
573
|
+
<div class="search-container">
|
|
574
|
+
<input
|
|
575
|
+
type="text"
|
|
576
|
+
class="search-input"
|
|
577
|
+
placeholder="Search in logs..."
|
|
578
|
+
oninput="handleSearch(event)"
|
|
579
|
+
>
|
|
580
|
+
<span class="match-count" id="match-count" style="display: none;"></span>
|
|
581
|
+
<div class="filter-buttons">
|
|
582
|
+
<button class="filter-btn error" onclick="toggleFilter('error')" title="Filter errors">Error</button>
|
|
583
|
+
<button class="filter-btn warn" onclick="toggleFilter('warn')" title="Filter warnings">Warn</button>
|
|
584
|
+
<button class="filter-btn info" onclick="toggleFilter('info')" title="Filter info">Info</button>
|
|
585
|
+
<button class="filter-btn debug" onclick="toggleFilter('debug')" title="Filter debug">Debug</button>
|
|
586
|
+
</div>
|
|
587
|
+
</div>
|
|
588
|
+
</div>
|
|
589
|
+
|
|
590
|
+
<div id="logs-container">
|
|
591
|
+
<div class="loading">Loading...</div>
|
|
592
|
+
</div>
|
|
593
|
+
</body>
|
|
594
|
+
</html>
|