or run

npx @tessl/cli init
Log in

Version

Files

docs

advanced-colors.mdbackground-colors.mdbasic-colors.mdcolor-support.mdconfiguration.mdindex.mdtext-styling.md
tile.json

task.mdevals/scenario-6/

Stream-Aware Console Formatter

A lightweight formatter that produces styled console strings with separate color handling for standard output and error output.

Capabilities

Configurable stdout color level

  • When created with a level of 0, info and warn return plain strings without ANSI color sequences while keeping prefixes. @test
  • With a level of 1, info wraps the message in a single color style while leaving the message text unchanged. @test

Stderr honors stream detection

  • error uses styling bound to the error stream and still emits colored output when color support is forced on (e.g., FORCE_COLOR=1), even if stdout is limited to level 0. @test

Distinct styling per severity

  • info, warn, and error return strings prefixed with their severity labels and apply different visual emphasis per severity. @test

Implementation

@generates

API

export type FormatterOptions = {
  level?: 0 | 1 | 2 | 3;
};

export type StreamFormatter = {
  info(message: string): string;
  warn(message: string): string;
  error(message: string): string;
};

export function createStreamFormatter(options?: FormatterOptions): StreamFormatter;

Dependencies { .dependencies }

chalk { .dependency }

Provides terminal string styling and stream-aware color detection.