Skip to content

Commit e9528be

Browse files
committed
feat: Memory Display
- Improved color logic
1 parent 1783b27 commit e9528be

File tree

4 files changed

+19
-10
lines changed

4 files changed

+19
-10
lines changed

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@
2222
"advanced",
2323
"logging",
2424
"file",
25-
"logging"
25+
"logging",
26+
"async-logging",
27+
"worker",
28+
"async"
2629
],
2730
"author": "Sam Estrin",
2831
"license": "MIT",

src/core/ACL.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ class ACL {
7373
fatal: config.color?.fatal || COLORS.MAGENTA,
7474
caller: config.color?.caller || COLORS.LIGHT_MAGENTA,
7575
inlineCaller: COLORS.LIGHT_CYAN,
76+
position: COLORS.CYAN,
7677
};
7778
this.space = config.extraSpace ? "\n" : "";
7879
this.generateReport = !!config.generateReport;
@@ -511,9 +512,9 @@ class ACL {
511512
case 1:
512513
return `${relativeFilePath}:`;
513514
case 2:
514-
return `${relativeFilePath} (${lineNumber}, ${columnNumber}):`;
515+
return `${relativeFilePath} ${this.color.position}(${lineNumber}, ${columnNumber})${this.color.inlineCaller}:`;
515516
case 3:
516-
return `${relativeFilePath} (${lineNumber}, ${columnNumber}) > ${callerFunction}:`;
517+
return `${relativeFilePath} ${this.color.position}(${lineNumber}, ${columnNumber})${this.color.inlineCaller} > ${callerFunction}:`;
517518
default:
518519
return "";
519520
}

src/lib/constants.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ const COLORS = {
1515
CYAN: "\u001b[36m", // For DEBUG
1616
LIGHT_MAGENTA: "\u001b[95m", // For caller info
1717
MAGENTA: "\u001b[35m", // For FATAL
18-
LIGHT_GRAY: "\u001b[37m", // For memory usage
18+
LIGHT_GRAY: "\u001b[37m", // Light grey
19+
DARK_GRAY: "\u001b[90m", // Dark grey
20+
WHITE: "\u001b[97m", // White
21+
ORANGE: "\u001b[93m", // Bright yellow (approximation for orange)
1922
RESET: "\u001b[0m", // Reset color
2023
};
2124

src/lib/memoryUtils.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,11 @@ function getMemoryUsagePercentage(totalHeapSizeLimit) {
5050
* @returns {string} - The color code for the memory usage.
5151
*/
5252
function getMemoryUsageColor(freePercentage) {
53-
if (freePercentage >= 75) return COLORS.LIGHT_GRAY;
54-
if (freePercentage >= 50) return COLORS.LIGHT_MAGENTA;
55-
if (freePercentage >= 25) return COLORS.LIGHT_RED;
53+
if (freePercentage >= 80) return COLORS.WHITE;
54+
if (freePercentage >= 70) return COLORS.YELLOW;
55+
if (freePercentage >= 60) return COLORS.ORANGE;
56+
if (freePercentage >= 50) return COLORS.LIGHT_RED;
57+
5658
return COLORS.RED;
5759
}
5860

@@ -70,11 +72,11 @@ function getFormattedMemoryUsage(totalHeapSizeLimit, memoryDisplayMode) {
7072

7173
switch (memoryDisplayMode) {
7274
case 1:
73-
return `${color}[${memoryInMB} MB Free]${COLORS.RESET} `;
75+
return `${COLORS.WHITE}[${color}${memoryInMB} MB Free${COLORS.WHITE}]${COLORS.RESET} `;
7476
case 2:
75-
return `${color}[${memoryInPercent}% Free]${COLORS.RESET} `;
77+
return `${COLORS.WHITE}[${color}${memoryInPercent}% Free${COLORS.WHITE}]${COLORS.RESET} `;
7678
case 3:
77-
return `${color}[${memoryInMB} MB Free / ${memoryInPercent}% Free]${COLORS.RESET} `;
79+
return `${COLORS.WHITE}[${color}${memoryInMB} MB Free / ${memoryInPercent}% Free${COLORS.WHITE}]${COLORS.RESET} `;
7880
default:
7981
return "";
8082
}

0 commit comments

Comments
 (0)