docs
evals
scenario-1
scenario-10
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
Build a status logging utility that displays formatted status information with colors for various data types.
Create a module that exports a function logStatus(label, value) which outputs formatted status lines to the console. The function should:
Accept a label (string) and a value of any type (number, boolean, null, undefined, or string)
Format the output as: [LABEL]: value where the label is displayed in cyan and the value is displayed in different colors based on its type:
true: greenfalse: rednull: grayundefined: grayThe entire output line should be prefixed with a timestamp in the format HH:MM:SS displayed in dim text
Handle edge cases like 0, NaN, Infinity, and empty strings appropriately
console.log() for outputProvides terminal color formatting support.
The following test cases should be implemented in status-logger.test.js:
// When logging a number
logStatus("Count", 42);
// Should output: 12:34:56 [COUNT]: 42
// Where timestamp is dim, COUNT is cyan, and 42 is yellow// When logging true
logStatus("Success", true);
// Should output: 12:34:56 [SUCCESS]: true
// Where timestamp is dim, SUCCESS is cyan, and true is green// When logging false
logStatus("Failed", false);
// Should output: 12:34:56 [FAILED]: false
// Where timestamp is dim, FAILED is cyan, and false is red// When logging null
logStatus("Data", null);
// Should output: 12:34:56 [DATA]: null
// Where timestamp is dim, DATA is cyan, and null is gray// When logging undefined
logStatus("Config", undefined);
// Should output: 12:34:56 [CONFIG]: undefined
// Where timestamp is dim, CONFIG is cyan, and undefined is gray// When logging zero
logStatus("Items", 0);
// Should output: 12:34:56 [ITEMS]: 0
// Where timestamp is dim, ITEMS is cyan, and 0 is yellow