Skip to content

Commit 8a28543

Browse files
committed
feat: add log colors
1 parent 0f2583d commit 8a28543

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/config.class.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ class ConfigClass {
1212
info: this.validateEmoji(logSymbols?.info) || "ℹ️",
1313
log: this.validateEmoji(logSymbols?.log) || "📄",
1414
},
15+
logColors: {
16+
success: "\x1b[32m",
17+
fail: "\x1b[31m",
18+
warn: "\x1b[33m",
19+
error: "\x1b[31m",
20+
info: "\x1b[36m",
21+
log: "\x1b[37m",
22+
},
1523
};
1624
}
1725

src/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const createLogger = (params) => {
66
const config = configInstance.getConfig();
77

88
const logSymbols = config.logSymbols;
9+
const logColors = config.logColors;
910

1011
const log = (level, ...args) => {
1112
const logFunction = {
@@ -21,7 +22,7 @@ const createLogger = (params) => {
2122
const isLoggingDisabled = config?.isLoggingDisabled;
2223

2324
if (isLoggingDisabled) return;
24-
logFunction[level](`${timestamp} ${logSymbols[level]}${config?.disablePrefixText ? "" : level.charAt(0).toUpperCase() + level.slice(1) + ": "}`, ...args);
25+
logFunction[level](`${logColors[level]}${timestamp} ${logSymbols[level]} ${config?.disablePrefixText ? "" : level.charAt(0).toUpperCase() + level.slice(1) + ": "}`, ...args);
2526
};
2627

2728
return {

0 commit comments

Comments
 (0)