Potunění utils funkce log

This commit is contained in:
Histmy 2025-05-13 14:42:10 +02:00
parent 3fed27d62e
commit d4df7b1417

View File

@ -90,15 +90,26 @@ export function adminLog(client: Client, text: string, err?: string | Error) {
} }
export function log(...content: unknown[]) { export function log(...content: unknown[]) {
let jeChyba = false; let hasError = false;
const jo = content.map(h => { const colored = content.map(entry => {
if (h instanceof Error) return `\x1b[31m${h.stack || h}\x1b[0m`; if (entry instanceof Error) {
return h; hasError = true;
return `\x1b[31m${entry.stack || entry}\x1b[0m`;
}
return entry;
}); });
const d = new Date(); const d = new Date();
console.log(`[${d.getDate()}.${d.getMonth() + 1}. ${d.getHours()}:${d.getMinutes()}:${d.getSeconds()}.${d.getMilliseconds()}]:`, ...jo);
const params = [`[${d.getDate()}.${d.getMonth() + 1}. ${d.getHours()}:${d.getMinutes()}:${d.getSeconds()}.${d.getMilliseconds()}]:`, ...colored];
if (hasError) {
console.error(...params);
} else {
console.log(...params);
}
} }
export async function sendDM(user: User, txt: string) { export async function sendDM(user: User, txt: string) {