Skip to content

Commit 1f66cba

Browse files
fix: Logger
1 parent 6edc244 commit 1f66cba

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

src/logger.mjs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,29 +21,37 @@ function log(...args) {
2121
* @param args The arguments to log
2222
*/
2323
function important(...args) {
24-
console.log(chalk.hex(orange)(...args));
24+
args = args.map((arg) =>
25+
typeof arg === 'string' ? chalk.hex(orange)(arg) : arg,
26+
);
27+
console.log(...args);
2528
}
2629
/**
2730
* Log an error message in red
2831
* @param args The arguments to log
2932
*/
3033
function error(...args) {
31-
console.error(chalk.red(...args));
34+
args = args.map((arg) => (typeof arg === 'string' ? chalk.red(arg) : arg));
35+
console.error(...args);
3236
}
3337
/**
3438
* Log a warning message in orange
3539
* @param args The arguments to log
3640
*/
3741
function warn(...args) {
38-
console.warn(chalk.hex(orange)(...args));
42+
args = args.map((arg) =>
43+
typeof arg === 'string' ? chalk.hex(orange)(arg) : arg,
44+
);
45+
console.warn(...args);
3946
}
4047
/**
4148
* Log a verbose message if verbose is enabled. Log the message in grey.
4249
* @param args The arguments to log
4350
*/
4451
function verbose(...args) {
4552
if (verboseEnabled) {
46-
console.info(chalk.grey(...args));
53+
args = args.map((arg) => (typeof arg === 'string' ? chalk.grey(arg) : arg));
54+
console.info(...args);
4755
}
4856
}
4957
/**

src/logger.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,30 @@ function log(...args: any[]) {
2323
* @param args The arguments to log
2424
*/
2525
function important(...args: any[]) {
26-
console.log(chalk.hex(orange)(...args));
26+
args = args.map((arg) =>
27+
typeof arg === 'string' ? chalk.hex(orange)(arg) : arg,
28+
);
29+
console.log(...args);
2730
}
2831

2932
/**
3033
* Log an error message in red
3134
* @param args The arguments to log
3235
*/
3336
function error(...args: any[]) {
34-
console.error(chalk.red(...args));
37+
args = args.map((arg) => (typeof arg === 'string' ? chalk.red(arg) : arg));
38+
console.error(...args);
3539
}
3640

3741
/**
3842
* Log a warning message in orange
3943
* @param args The arguments to log
4044
*/
4145
function warn(...args: any[]) {
42-
console.warn(chalk.hex(orange)(...args));
46+
args = args.map((arg) =>
47+
typeof arg === 'string' ? chalk.hex(orange)(arg) : arg,
48+
);
49+
console.warn(...args);
4350
}
4451

4552
/**
@@ -48,7 +55,8 @@ function warn(...args: any[]) {
4855
*/
4956
function verbose(...args: any[]) {
5057
if (verboseEnabled) {
51-
console.info(chalk.grey(...args));
58+
args = args.map((arg) => (typeof arg === 'string' ? chalk.grey(arg) : arg));
59+
console.info(...args);
5260
}
5361
}
5462

0 commit comments

Comments
 (0)