diff --git a/src/utils/utils.ts b/src/utils/utils.ts index 5971bf4..58d8688 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -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) {