feat(lib/log): doing a wrapper for the log
- Now the log will be unifed
This commit is contained in:
parent
690255b863
commit
a9ac3eeec8
1 changed files with 25 additions and 0 deletions
25
src/lib/log.ts
Normal file
25
src/lib/log.ts
Normal file
|
|
@ -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}`));
|
||||||
|
},
|
||||||
|
};
|
||||||
Loading…
Add table
Add a link
Reference in a new issue