mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-27 07:52:24 +00:00
Revert "Refactor logging to centralized logger"
This commit is contained in:
1 parent
2e7038e0e6
commit
d705cf176b
67 files changed
+798
-1130
No files matched your search
@@ -225,26 +225,6 @@
|
||||
</div>
|
||||
<script>
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
const fallbackChannel = {
|
||||
log: () => {},
|
||||
info: () => {},
|
||||
warn: () => {},
|
||||
error: () => {},
|
||||
};
|
||||
const embeddedLogger =
|
||||
(typeof window !== "undefined" && window.bitvidLogger) || {};
|
||||
const devChannel = embeddedLogger.dev || fallbackChannel;
|
||||
const userChannel = embeddedLogger.user || fallbackChannel;
|
||||
const emitDev = (method, ...args) => {
|
||||
if (typeof devChannel[method] === "function") {
|
||||
devChannel[method](...args);
|
||||
}
|
||||
};
|
||||
const emitUser = (method, ...args) => {
|
||||
if (typeof userChannel[method] === "function") {
|
||||
userChannel[method](...args);
|
||||
}
|
||||
};
|
||||
// Logging functions for both on-page and console output.
|
||||
function log(msg, type = "info") {
|
||||
const div = document.createElement("div");
|
||||
@@ -254,14 +234,7 @@
|
||||
if (type === "warn") div.classList.add("warn");
|
||||
div.textContent = msg;
|
||||
document.getElementById("status").appendChild(div);
|
||||
const normalized = type.toLowerCase();
|
||||
if (normalized === "error") {
|
||||
emitUser("error", `[${type.toUpperCase()}] ${msg}`);
|
||||
} else if (normalized === "warn") {
|
||||
emitUser("warn", `[${type.toUpperCase()}] ${msg}`);
|
||||
} else {
|
||||
emitDev("info", `[${type.toUpperCase()}] ${msg}`);
|
||||
}
|
||||
console.log(`[${type.toUpperCase()}] ${msg}`);
|
||||
}
|
||||
function clear() {
|
||||
document.getElementById("status").innerHTML = "";
|
||||
@@ -484,7 +457,7 @@ For further questions, contact us through bitvid’s Nostr support channels.
|
||||
);
|
||||
} catch (err) {
|
||||
log("Error: " + err.message, "error");
|
||||
emitUser("error", err);
|
||||
console.error(err);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user