Files
dandelion/static/log.js
bobbydigitales d0fd041f7e Add deno-only bootstrap peer implementation. Uses libdatachannel for the RTCDatachannel implementation.
Fix Typescript sourcemap serving
PeerManager: more robust when RTCPeerConnection fails or is not present
Separate source maps so the main files arent bloated
2025-06-10 20:23:19 -07:00

40 lines
1.1 KiB
JavaScript

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];
}
//# sourceMappingURL=log.js.map