mirror of
https://github.com/vladmandic/automatic
synced 2026-09-02 02:50:47 +02:00
add log monitoring
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
let logMonitorEl = null;
|
||||
|
||||
async function logMonitor() {
|
||||
setTimeout(logMonitor, opts.logmonitor_refresh_period);
|
||||
if (logMonitorEl) logMonitorEl.parentElement.style.display = opts.logmonitor_show ? 'block' : 'none';
|
||||
if (!opts.logmonitor_show) return;
|
||||
const res = await fetch('/sdapi/v1/log?clear=True');
|
||||
if (res?.ok) {
|
||||
if (!logMonitorEl) logMonitorEl = document.getElementById('logMonitorData');
|
||||
if (!logMonitorEl) return;
|
||||
logMonitorEl.parentElement.style.display = 'block';
|
||||
const lines = await res.json();
|
||||
for (const line of lines) {
|
||||
const l = JSON.parse(line);
|
||||
const row = document.createElement("tr");
|
||||
row.style = 'padding: 10px; margin: 0;';
|
||||
row.innerHTML = `<td>${new Date(1000 * l.created).toISOString()}</td><td>${l.level}</td><td>${l.facility}</td><td>${l.module}</td><td>${l.msg}</td>`;
|
||||
logMonitorEl.appendChild(row);
|
||||
while (logMonitorEl.childElementCount > 100) logMonitorEl.removeChild(logMonitorEl.firstChild);
|
||||
logMonitorEl.scrollTop = logMonitorEl.scrollHeight
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function logMonitorCreate() {
|
||||
const el = document.getElementsByTagName('footer')[0];
|
||||
if (!el) return;
|
||||
el.classList.add('log-monitor');
|
||||
el.innerHTML = `
|
||||
<table style="width: 100%">
|
||||
<thead style="display: block; text-align: left; border-bottom: solid 1px var(--button-primary-border-color)">
|
||||
<tr>
|
||||
<th style="width: 170px">Time</th>
|
||||
<th>Level</th>
|
||||
<th style="width: 72px">Facility</th>
|
||||
<th style="width: 124px">Module</th>
|
||||
<th>Message</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="logMonitorData" style="white-space: nowrap; height: 10vh; width: 100vw; display: block; overflow-x: hidden; overflow-y: scroll">
|
||||
</tbody>
|
||||
</table>
|
||||
`;
|
||||
logMonitor();
|
||||
}
|
||||
@@ -58,7 +58,10 @@ async function setHints() {
|
||||
];
|
||||
if (elements.length === 0) return;
|
||||
if (Object.keys(opts).length === 0) return;
|
||||
if (!locale.el) tooltipCreate();
|
||||
if (!locale.el) {
|
||||
tooltipCreate();
|
||||
logMonitorCreate();
|
||||
}
|
||||
let localized = 0;
|
||||
let hints = 0;
|
||||
locale.finished = true;
|
||||
+11
-3
@@ -49,9 +49,6 @@ button.custom-button{
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* remove footer */
|
||||
footer { display: none !important; }
|
||||
|
||||
/* themes */
|
||||
.theme-preview { display: none; position: fixed; border: 4px solid var(--neutral-600); box-shadow: 2px 2px 2px 2px var(--neutral-700); top: 0; bottom: 0; left: 0; right: 0; margin: auto; max-width: 75vw; z-index: 999; }
|
||||
|
||||
@@ -668,3 +665,14 @@ div.controlnet_main_options { display: grid; grid-template-columns: 1fr 1fr; gri
|
||||
#refresh_tac_refreshTempFiles { display: none; }
|
||||
#train_tab { flex-flow: row-reverse; }
|
||||
#models_tab { flex-flow: row-reverse; }
|
||||
|
||||
.log-monitor {
|
||||
display: none;
|
||||
justify-content: unset !important;
|
||||
overflow: hidden;
|
||||
padding: 0;
|
||||
margin-top: auto;
|
||||
font-family: monospace;
|
||||
font-size: 0.85em;
|
||||
}
|
||||
.log-monitor td, .log-monitor th { padding-left: 1em; }
|
||||
|
||||
Reference in New Issue
Block a user