rgb-console v1.0.2
RGB Console for Node.js Server
Author: Matan Aviav. E-mail: matanaviav.npmjs@gmail.com Style your Node.js Server console (terminal) with text colors, background colors and symbols. Example (Terminal of WebStorm):
And the code for the above output:
const cc = require('rgb-console');
cc.log('A plain text...')
cc.title('This is a title')
cc.error('File not found!')
cc.ok('The process has finished successfully!');
cc.warn('Your website is running on development mode!');
cc.whiteBG('This background is white! Cool!')
cc.bg('I love Magenta as background color! Nice!', cc.BG_COLORS.MAGENTA)
cc.bold('This is a bolded text', cc.TEXT_COLORS.GREEN);
cc.redBold('This is a red bolded text');
cc.underlineBlue("This is an underlined text")
cc.underlineBlue("This is an underlined bolded text", true)
cc.underline("This is an underlined bolded text", cc.TEXT_COLORS.MAGENTA, true)How to use?
1. Install the module:
First, install the module in your project folder with the following command:
npm install rgb-console2. Import the module:
First, import the module into a variable with require() function:
const cc = require('rgb-console')3. Use it:
Use the different functions the variable has. Examples:
const cc = require('rgb-console');
cc.log('A plain text...')
cc.title('This is a title')
cc.error('File not found!')
cc.ok('The process has finished successfully!');
cc.warn('Your website is running on development mode!');
cc.whiteBG('This background is white! Cool!')
cc.bg('I love Magenta as background color! Nice!', cc.BG_COLORS.MAGENTA)
cc.bold('This is a bolded text', cc.TEXT_COLORS.GREEN);
cc.redBold('This is a red bolded text');Documentation:
1. Plain Text (no style):
For plain text use log(...) function.
RGBConsole.log() function is the same function as console.log(...) of JavaScript.
2. Title Style:
You can use title(...) function for a bold title.
The title(...) function will output a message which has:
(-) A Cyan Background Color
(-) A Black Text ColorExample:
const cc = require('rgb-console');
cc.title('This is a title');Output:
3. Colored Text:
Note: you can run RGBConsole run text examples for a quick tutorial.
For colored text use functions with text prefix.
For example, calling textBlue('Some Text') will output:
The functions for colored text are:
textWhite("Some Text")
textRed("Some Text")
textGreen("Some Text")
textYellow("Some Text")
textBlack("Some Text")
textBlue("Some Text")
textCyan("Some Text")
textMagenta("Some Text")You can also use shorthand functions:
white("Some Text")
red("Some Text")
green("Some Text")
yellow("Some Text")
black("Some Text")
blue("Some Text")
cyan("Some Text")
magenta("Some Text")Preview of the colors:
4. Colored Bolded Text:
Note: you can run RGBConsole run bold examples for a quick tutorial.
For colored bolded text use functions with bold prefix.
For example, calling boldMagenta('Some Text') will output:
The functions for colored bolded text are:
boldWhite("Some Text")
boldRed("Some Text")
boldGreen("Some Text")
boldYellow("Some Text")
boldBlack("Some Text")
boldBlue("Some Text")
boldCyan("Some Text")
boldMagenta("Some Text")You can also use the same functions but with color name as prefix and Bold as suffix:
whiteBold("Some Text")
redBold("Some Text")
greenBold("Some Text")
yellowBold("Some Text")
blackBold("Some Text")
blueBold("Some Text")
cyanBold("Some Text")
magentaBold("Some Text")You can also use bold(...) function directly with the following parameters:
(1) text: string - A Text
(2) text_color: string - A Text Color from RGBConsole.TEXT_COLORS object:
BLACK
BLUE
CYAN
GREEN
MAGENTA
RED
WHITE
YELLOWExample:
const cc = require('rgb-console');
cc.bold('Some Text', cc.TEXT_COLORS.MAGENTA);Output:
Preview of the bolded text colors:
5. Colored Underlined Text:
Note: you can run RGBConsole run underline examples for a quick tutorial.
For colored underlined text use functions with underline prefix.
For example, calling underlineYellow('Some Text') will output:
All functions for colored underlined text accept the following optional second parameter:
isBold?: boolean - Make the text bolded (Optional). Default: falseThe functions for colored underlined text are:
underlineWhite("Some Text")
underlineRed("Some Text")
underlineGreen("Some Text")
underlineYellow("Some Text")
underlineBlack("Some Text")
underlineBlue("Some Text")
underlineCyan("Some Text")
underlineMagenta("Some Text")You can also use the same functions but with color name as prefix and Underline as suffix:
whiteUnderline("Some Text")
redUnderline("Some Text")
greenUnderline("Some Text")
yellowUnderline("Some Text")
blackUnderline("Some Text")
blueUnderlined("Some Text")
cyanUnderline("Some Text")
magentaUnderline("Some Text")Example:
const cc = require('rgb-console');
cc.underlineGreen('Some Text');
cc.blueUnderline('Some Text', true);Output:
You can also use underline(...) function directly with the following parameters:
(1) text: string - A Text
(2) text_color: string - A Text Color from RGBConsole.TEXT_COLORS object:
BLACK
BLUE
CYAN
GREEN
MAGENTA
RED
WHITE
YELLOW
(3) isBold?: boolean - Make the text bolded (Optional). Default: falseExample:
const cc = require('rgb-console');
cc.underline('Some Text', cc.TEXT_COLORS.MAGENTA);Output:
Preview of the underlined text colors:
6. Colored Background:
Note: you can run RGBConsole run background examples for a quick tutorial.
For colored background use functions with BG prefix.
For example, calling BGRed('Some Text') will output:
The functions for colored background are:
BGWhite("Some Text")
BGBlue("Some Text")
BGRed("Some Text")
BGGreen("Some Text")
BGYellow("Some Text")
BGCyan("Some Text")
BGMagenta("Some Text")You can also use the same functions but with color name as prefix and BG as suffix:
whiteBG("Some Text")
blueBG("Some Text")
redBG("Some Text")
greenBG("Some Text")
yellowBG("Some Text")
cyanBG("Some Text")
magentaBG("Some Text")You can also use bg(...) function directly with the following parameters:
(1) text: string - A Text
(2) bg_color: string - A Background Color from RGBConsole.BG_COLORS object:
WHITE
BLUE
RED
GREEN
YELLOW
CYAN
MAGENTA
(3) text_color?: string - A text color from RGBConsole.TEXT_COLORS object (Optional). Default text color: BLACKExample:
const cc = require('rgb-console');
cc.bg('Some Text', cc.BG_COLORS.CYAN);Output:
Preview of the colors:
7. Error/Negative Messages:
Note: you can run RGBConsole run error examples for a quick tutorial.
For Error/Negative messages use error(...), bad(...) or fail(...) functions.
For example, calling error('Some Text') will output:
By default, error(...) function will output a message which has:
(-) A Red Background Color
(-) A X symbol at the beginning
(-) The word 'ERROR' as prefixNote that error(...) function does accept the following parameters:
(1) text: string - A Text
(2) options?: object (Optional) - An object with the following properties:
(a) removeSymbol?: boolean - Remove the X symbol from the beginning (Optional)
(b) newPrefix?: string - A new prefix at the beginning (Optional)Examples:
Calling
error("Some Text", {removeSymbol: true})will output:
Calling
error("Some Text", {removeSymbol: true, newPrefix: "CustomPrefix"})will output:
Calling
error("Some Text", {removeSymbol: true, newPrefix: ""})will output:
Calling
error("Some Text")will output:
The bad(...) and fail(...) Functions:
The bad(...) and fail(...) functions are the same as error(...) function but with one difference:
(-) By default, bad(...) function has the word 'BAD' as prefix
(-) By default, fail(...) function has the word 'FAIL' as prefix8. Success/Positive Messages:
Note: you can run RGBConsole run ok examples for a quick tutorial.
For Success/Positive messages use ok(...), success(...) or good(...) functions.
For example, calling ok('Some Text') will output:
By default, ok(...) function will output a message which has:
(-) A Green Background Color
(-) A check symbol at the beginning
(-) The word 'OK' as prefixNote that ok(...) function does accept the following parameters:
(1) text: string - A Text
(2) options?: object (Optional) - An object with the following properties:
(a) removeSymbol?: boolean - Remove the check symbol from the beginning (Optional)
(b) newPrefix?: string - A new prefix at the beginning (Optional)Examples:
Calling
ok("Some Text", {removeSymbol: true})will output:
Calling
ok("Some Text", {removeSymbol: true, newPrefix: "CustomPrefix"})will output:
Calling
ok("Some Text", {removeSymbol: true, newPrefix: ""})will output:
Calling
ok("Some Text")will output:
The success(...) and good(...) Functions:
The success(...) and good(...) functions are the same as ok(...) function but with one difference:
(-) By default, success(...) function has the word 'SUCCESS' as prefix
(-) By default, good(...) function has the word 'GOOD' as prefix9. Warning Messages:
Note: you can run RGBConsole run warn examples for a quick tutorial.
For Warning messages use warn(...) function.
For example, calling warn('Some Text') will output:
By default, warn(...) function will output a message which has:
(-) A Yellow Background Color
(-) A Warning symbol at the beginning
(-) The word 'WARNING' as prefixNote that warn(...) function does accept the following parameters:
(1) text: string - A Text
(2) options?: object (Optional) - An object with the following properties:
(a) removeSymbol?: boolean - Remove the Warning symbol from the beginning (Optional)
(b) newPrefix?: string - A new prefix at the beginning (Optional)Examples:
Calling
warn("Some Text", {removeSymbol: true})will output:
Calling
warn("Some Text", {removeSymbol: true, newPrefix: "CustomPrefix"})will output:
Calling
warn("Some Text", {removeSymbol: true, newPrefix: ""})will output:
Calling
warn("Some Text")will output:
















