From a9ac3eeec83cf308575d7addc07ebb132df22662 Mon Sep 17 00:00:00 2001 From: Raphael Date: Sun, 26 Oct 2025 17:36:51 +0100 Subject: [PATCH] feat(lib/log): doing a wrapper for the log - Now the log will be unifed --- src/lib/log.ts | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/lib/log.ts diff --git a/src/lib/log.ts b/src/lib/log.ts new file mode 100644 index 0000000..760c078 --- /dev/null +++ b/src/lib/log.ts @@ -0,0 +1,25 @@ +import chalk from 'chalk'; + +export const log = { + warn: (err: unknown, str?: string) => { + const error = err instanceof Error ? err : new Error(String(err)); + console.warn(chalk.yellowBright(`⚠️ | ${str ? ` during ${str}` : ''}`)); + console.warn(chalk.yellowBright(`\t${error.message}`)); + console.warn(chalk.yellowBright(`\tStack:\n${error.stack ?? 'No stack available'}`)); + }, + error: (err: unknown, str?: string) => { + const error = err instanceof Error ? err : new Error(String(err)); + console.error(chalk.redBright(`❌ | Error${str ? ` during ${str}` : ''}`)); + console.error(chalk.redBright(`\t${error.message}`)); + console.error(chalk.redBright(`\tStack:\n${error.stack ?? 'No stack available'}`)); + }, + success: (str: string) => { + console.log(chalk.greenBright(`✅ | ${str}`)); + }, + search: (name: string) => { + console.log(chalk.blueBright(`🔍 | Searching for ${name}`)); + }, + list: (name: string) => { + console.log(chalk.cyanBright(`\t✅ | ${name}`)); + }, +};