A lightweight TypeScript console wrapper with support for color tags and quiet mode.
- Color Tags: Use XML-style tags to colorize console output
- Quiet Mode: Suppress all output when needed
- Color Toggle: Disable colors for CI environments or plain text output
- Customizable Colors: Define your own color map using Chalk
- TypeScript Support: Full type definitions included
npm install @northern/consoleimportConsolefrom'@northern/console';constconsole=newConsole();// Use color tags to format outputconsole.write('Run <command>npm install</command> to get started');console.write('This is <highlight>important</highlight>!');console.write('Status: <success>Complete</success>');// Create a quiet console that suppresses all outputconstquietConsole=newConsole(true);quietConsole.write('This will not appear');// No output// Create a console without colors (useful for CI environments)constplainConsole=newConsole(false,false);plainConsole.write('Run <command>npm test</command>');// Output: "Run npm test"importchalkfrom'chalk';constcustomColors={command: chalk.green,highlight: chalk.yellow,error: chalk.bgRed.whiteBright,warning: chalk.bgYellow.black,info: chalk.bgBlue.whiteBright,success: chalk.bgGreen.whiteBright,custom: chalk.magenta.bold,};constconsole=newConsole(false,true,customColors);console.write('This is <custom>custom colored</custom> text');constconsole=newConsole();constdata={user: {name: 'John',age: 30},settings: {theme: 'dark'}};// Dump with full depth and colorsconsole.dump(data);newConsole(isQuiet?: boolean,isColor?: boolean,colorMap?: Record<string,ChalkInstance>)Parameters:
isQuiet(optional): Whentrue, suppresses all output. Defaults tofalse.isColor(optional): Whentrue, enables color output. Defaults totrue.colorMap(optional): Custom color mapping using Chalk instances.
Writes output to the console with color tag processing. Suppressed in quiet mode.
Example:
console.write('Status: <success>OK</success>');console.write('Multiple','arguments','supported');Dumps an object to the console with full depth and colors. Useful for debugging. Suppressed in quiet mode.
Example:
console.dump({complex: {nested: {object: true}}});The following color tags are available by default:
<command>text</command>- Green text<highlight>text</highlight>- Yellow text<error>text</error>- White text on red background<warning>text</warning>- Black text on yellow background<info>text</info>- White text on blue background<success>text</success>- White text on green background
MIT