Core

/client/src/audit.ts (731 B)

 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
import {opt} from "./dom";

function renderAudit(msg: string, ...codes: any) { // eslint-disable-line @typescript-eslint/no-explicit-any
const li = document.createElement("li");
li.innerText = msg;
for (const code of codes) {
const pre = document.createElement("pre");
if (typeof code === "string") {
pre.innerText = code;
} else {
pre.innerText = JSON.stringify(code, null, 2);
}
li.appendChild(pre);
}
return li;
}

export function audit(msg: string, ...codes: any) { // eslint-disable-line @typescript-eslint/no-explicit-any
const el = opt("#audit-log");
if (el) {
el.appendChild(renderAudit(msg, ...codes));
} else {
console.log("### Audit ###\n" + msg, ...codes);
}
}