or run

npx @tessl/cli init
Log in

Version

Files

tile.json

task.mdevals/scenario-5/

CLI Status Logger

A simple command-line status logger that outputs messages with appropriate color coding based on message severity levels.

Requirements

Implement a status logging utility that accepts messages with different severity levels and outputs them to the console with appropriate color coding:

  • Error messages: Display in red
  • Warning messages: Display in yellow
  • Success messages: Display in green
  • Info messages: Display in cyan
  • Debug messages: Display in magenta
  • Trace messages: Display in gray
  • Critical messages: Display in black on default background

The logger should:

  1. Accept a message string and a severity level
  2. Apply the appropriate color based on the severity level
  3. Output the colored message to the console
  4. Handle invalid severity levels by displaying them in white

Test Cases

  • It logs error messages in red @test
  • It logs warning messages in yellow @test
  • It logs success messages in green @test
  • It logs info messages in cyan @test
  • It logs debug messages in magenta @test
  • It logs trace messages in gray @test
  • It logs critical messages in black @test
  • It handles unknown severity levels by displaying in white @test

Implementation

@generates

API

export function log(message, level);

The log function accepts:

  • message (string): The message to display
  • level (string): The severity level - one of: "error", "warning", "success", "info", "debug", "trace", "critical"

Dependencies { .dependencies }

picocolors { .dependency }

Provides terminal color formatting support.