docs
evals
scenario-1
scenario-10
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
Build a log formatter that composes reusable style builders and applies them to level prefixes using the dependency's chainable styling system.
['bgBlue', 'white', 'bold']), makeStyler returns a function that applies the combined styles to any text without altering its spacing or newlines. @testinfo → ['cyan', 'bold'], warn → ['yellow', 'bold'], error → ['whiteBright', 'bgRed'], debug → ['gray']. @testformatLog('info', ['Server', 'ready']) returns [INFO] Server ready with only the prefix styled by the info tokens; message parts are joined with single spaces and left unstyled. @testformatLog('error', ['Oops']) applies the error style tokens to [ERROR] while leaving the message untouched. @testcustomStyles.warn overrides the warn prefix styling while other levels keep defaults; e.g., formatLog('warn', ['Disk', '80%'], { customStyles: { warn: ['bgYellow', 'black'] } }) styles [WARN] with the provided tokens and returns [WARN] Disk 80%. @testdisableColor is true, formatted output contains no ANSI escape sequences or styling and returns plain text such as [WARN] Disk 80%. @testexport type LogLevel = 'info' | 'warn' | 'error' | 'debug';
export interface FormatOptions {
customStyles?: Partial<Record<LogLevel, string[]>>;
disableColor?: boolean;
}
/**
* Returns a function that applies the combined styles named in `styleNames`
* to any provided text. When `styleNames` is empty, it returns an identity
* function.
*/
export function makeStyler(styleNames: string[]): (text: string) => string;
/**
* Formats a log line: styles the `[LEVEL]` prefix for the provided level,
* joins message parts with single spaces, and honors any custom styles or
* opt-out of colorization.
*/
export function formatLog(
level: LogLevel,
parts: string[],
options?: FormatOptions
): string;Provides chainable styling builders for coloring strings.