colorprint

Print ansi-colored message to stdout/stderr.

Usage no npm install needed!

<script type="module">
  import colorprint from 'https://cdn.skypack.dev/colorprint';
</script>

README

colorprint

Build Status npm Version JS Standard

Print ansi-colored message to stdout/stderr.

Installation

npm install colorprint --save

Usage

"use strict";

const colorpint = require('colorpint')

colorpint.notice('This is NOTICE') //Pipe to stdout with magenta color.
colorpint.info('This is INFO') //Pipe to stdout with green color.
colorpint.debug('This is DEBUG') //Pipe to stdout with  color.
colorpint.trace('This is TRACE') //Pipe to stdout with white color.
colorpint.warn('This is WARN') //Pipe to stdout with yellow color.
colorpint.error('This is ERROR') //Pipe to stderr with red color.
colorpint.fatal('This is FATAL') //Pipe to stderr with bgRed color.

Using via CIL

Install globally

$ npm install colorprint -g

From Command Line

#!/bin/bash

colorpint notice "This is NOTICE from CLI" # Pipe to stdout with magenta color.
colorpint info "This is INFO from CLI" # Pipe to stdout with green color.
colorpint debug "This is DEBUG from CLI" # Pipe to stdout with  color.
colorpint trace "This is TRACE from CLI" # Pipe to stdout with white color.
colorpint warn "This is WARN from CLI" # Pipe to stdout with yellow color.
colorpint error "This is ERROR from CLI" # Pipe to stderr with red color.
colorpint fatal "This is FATAL from CLI" # Pipe to stderr with bgRed color.


Customizing

Customize the whole module.

"use strict";

const colorprint = require('colorprint');
colorprint.PREFIX='Yeah!';
colorprint.INFO_COLOR='blue';
colorprint.info('This will be blue with prefix.');

Create new context to customize.

"use strict";

const Colorprint = require('colorprint/lib/colorprint');
let colorprint = new Colorprint({
    PREFIX: '[Foo]',
    INFO_COLOR: 'blue'
});
colorprint.info('This will be blue with prefix.');


colorprint is using cli-color for coloring and you can see available colors here.

License

This software is released under the MIT License.