File size: 1,659 Bytes
ff50694
c17ec01
ff50694
 
 
c17ec01
 
 
 
 
 
 
 
 
 
 
 
 
ff50694
c17ec01
ff50694
 
 
 
c17ec01
 
 
 
 
 
 
 
 
 
ff50694
 
 
 
 
 
c17ec01
ff50694
 
c17ec01
ff50694
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
APP.ui.logging = {};

APP.ui.logging.log = function (msg, type = "i") {
    const { $ } = APP.core.utils;
    const consoleHook = $("#sysLog"); // Fixed ID: sysLog from html
    if (!consoleHook) return;
    const div = document.createElement("div");
    div.className = "log-line";
    const ts = new Date().toISOString().split("T")[1].slice(0, 8);
    let color = "#94a3b8"; // dim
    if (type === "g") color = "var(--good)";
    if (type === "w") color = "var(--warn)";
    if (type === "e") color = "var(--bad)";
    if (type === "t") color = "var(--theme)";

    div.innerHTML = `<span class="ts">[${ts}]</span> <span style="color:${color}">${msg}</span>`;
    consoleHook.appendChild(div);
    consoleHook.scrollTop = consoleHook.scrollHeight;
};

APP.ui.logging.setStatus = function (level, text) {
    const { $ } = APP.core.utils;
    const sysDot = $("#sys-dot");
    const sysStatus = $("#sys-status");
    if (!sysDot || !sysStatus) return;
    let color = "var(--text-dim)";
    if (level === "good") color = "var(--good)";
    if (level === "warn") color = "var(--warn)";
    if (level === "bad") color = "var(--bad)";

    sysDot.style.background = color;
    sysDot.style.boxShadow = `0 0 10px ${color}`;
    sysStatus.textContent = text;
    sysStatus.style.color = color === "var(--text-dim)" ? "var(--text-main)" : color;
};

APP.ui.logging.setHfStatus = function (msg) {
    const { $ } = APP.core.utils;
    const el = $("#hfBackendStatus");
    if (el) el.textContent = `HF Backend: ${msg}`;

    if (msg && (msg.toLowerCase().includes("error") || msg.toLowerCase().includes("failed"))) {
        APP.ui.logging.log(msg, "e");
    }
};