or run

npx @tessl/cli init
Log in

Version

Files

tile.json

task.mdevals/scenario-7/

Status Logger

Build a status logging utility that displays formatted status information with colors for various data types.

Requirements

Create a module that exports a function logStatus(label, value) which outputs formatted status lines to the console. The function should:

  1. Accept a label (string) and a value of any type (number, boolean, null, undefined, or string)

  2. 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:

    • Numbers: yellow
    • Boolean true: green
    • Boolean false: red
    • null: gray
    • undefined: gray
    • Strings: white
  3. The entire output line should be prefixed with a timestamp in the format HH:MM:SS displayed in dim text

  4. Handle edge cases like 0, NaN, Infinity, and empty strings appropriately

Implementation Notes

  • Use console.log() for output
  • The timestamp can be a placeholder (e.g., "12:34:56") for testing purposes
  • Ensure proper spacing and formatting for readability

Dependencies { .dependencies }

picocolors { .dependency }

Provides terminal color formatting support.

Test Cases { .test }

The following test cases should be implemented in status-logger.test.js:

Test: Logging numeric values { @test }

// 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

Test: Logging boolean true { @test }

// When logging true
logStatus("Success", true);
// Should output: 12:34:56 [SUCCESS]: true
// Where timestamp is dim, SUCCESS is cyan, and true is green

Test: Logging boolean false { @test }

// When logging false
logStatus("Failed", false);
// Should output: 12:34:56 [FAILED]: false
// Where timestamp is dim, FAILED is cyan, and false is red

Test: Logging null value { @test }

// When logging null
logStatus("Data", null);
// Should output: 12:34:56 [DATA]: null
// Where timestamp is dim, DATA is cyan, and null is gray

Test: Logging undefined value { @test }

// When logging undefined
logStatus("Config", undefined);
// Should output: 12:34:56 [CONFIG]: undefined
// Where timestamp is dim, CONFIG is cyan, and undefined is gray

Test: Logging zero { @test }

// When logging zero
logStatus("Items", 0);
// Should output: 12:34:56 [ITEMS]: 0
// Where timestamp is dim, ITEMS is cyan, and 0 is yellow