datasquirel/dist/package-shared/utils/logging/debug-log.js
Benjamin Toby 7e8bb37c09 Updates
2025-07-05 14:59:30 +01:00

31 lines
1000 B
JavaScript

import { ccol } from "../console-colors";
const LogTypes = ["error", "warning"];
export default function debugLog({ log, label, title, type, addTime }) {
const logType = (() => {
switch (type) {
case "error":
return ccol.FgRed;
case "warning":
return ccol.FgYellow;
default:
return ccol.FgGreen;
}
})();
let logTxt = `${logType}DEBUG${ccol.Reset}:::`;
const date = new Date();
const time = date.toLocaleTimeString("en-US", {
hour: "numeric",
minute: "numeric",
second: "numeric",
hour12: true,
});
const logTime = `${date.toLocaleDateString()}][${time}`;
if (addTime)
logTxt = `${ccol.BgWhite}[${logTime}]${ccol.Reset} ` + logTxt;
if (title)
logTxt += `${ccol.FgBlue}${title}${ccol.Reset}::`;
if (label)
logTxt += `${ccol.FgWhite}${ccol.Bright}${label}${ccol.Reset} =>`;
console.log(logTxt, log);
}