Add missing compiled files so we dont need to complie from a clean clone
This commit is contained in:
39
static/log.js
Normal file
39
static/log.js
Normal file
@@ -0,0 +1,39 @@
|
||||
let logLines = [];
|
||||
let logLength = 100;
|
||||
let logVisible = false;
|
||||
export function logID(ID) {
|
||||
if (!ID) {
|
||||
return "badID";
|
||||
}
|
||||
return ID.substring(0, 5);
|
||||
}
|
||||
export function setLogVisibility(visible) {
|
||||
logVisible = visible;
|
||||
}
|
||||
export function renderLog() {
|
||||
if (!logVisible) {
|
||||
return;
|
||||
}
|
||||
let log = document.getElementById("log");
|
||||
if (!log) {
|
||||
throw new Error();
|
||||
}
|
||||
log.innerText = logLines.join("\n");
|
||||
}
|
||||
export function log(...args) {
|
||||
// console.log(...args);
|
||||
let logLine = `[${new Date().toLocaleTimeString()}]: `;
|
||||
for (let arg of args) {
|
||||
let completeLine = (typeof arg === "string" || arg instanceof String) ? arg : JSON.stringify(arg, null, 4);
|
||||
if (completeLine === undefined) {
|
||||
completeLine = "undefined";
|
||||
}
|
||||
logLine += completeLine.substring(0, 500);
|
||||
}
|
||||
logLines.push(logLine + "\n");
|
||||
if (logLines.length > logLength) {
|
||||
logLines = logLines.slice(logLines.length - logLength);
|
||||
}
|
||||
renderLog();
|
||||
return [logLine]; // [...args];
|
||||
}
|
||||
Reference in New Issue
Block a user