Potunění utils funkce log
This commit is contained in:
parent
3fed27d62e
commit
d4df7b1417
@ -90,15 +90,26 @@ export function adminLog(client: Client, text: string, err?: string | Error) {
|
||||
}
|
||||
|
||||
export function log(...content: unknown[]) {
|
||||
let jeChyba = false;
|
||||
let hasError = false;
|
||||
|
||||
const jo = content.map(h => {
|
||||
if (h instanceof Error) return `\x1b[31m${h.stack || h}\x1b[0m`;
|
||||
return h;
|
||||
const colored = content.map(entry => {
|
||||
if (entry instanceof Error) {
|
||||
hasError = true;
|
||||
return `\x1b[31m${entry.stack || entry}\x1b[0m`;
|
||||
}
|
||||
|
||||
return entry;
|
||||
});
|
||||
|
||||
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) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user