Description
debugmessage is a simple module for node.js that provides utility to write colored command line in debug nodejs script
Requirements
- node.js -- v0.8.0 or newer
Install
npm install debugmessage
Examples
- simple base method to write cmd message colored (es6)
;let log=;log;log;log;
write on console
[DEBUG] this is only a debug
[COMMAND] this is only a command
[ERROR] this is only a error
DEBUG is a cyan foreground color COMMAND is a yellow foreground color ERROR is a red foreground color
description
module debugmessage use ansi colors to colorize the console log label on squares. Each color is a single method write it in lowercase
Foreground colors
- black
- red
- green
- yellow
- blue
- magenta
- cyan
- white
Background colors
- bgblack
- bgred
- bggreen
- bgyellow
- bgblue
- bgmagenta
- bgcyan
- bgwhite
;let log=;let green=log;console;//normal console but colored//or you can print with modulelog;//use background color greenlog;//-------------------------// simple testlog;
npm run test (grunt run:test)
API
Events
Property
- print< boolean >: show/hide message in commandline
Methods
-
(constructor)() - Creates the dynamic sequences colors method.
-
addLabel(labelstring:string,color:string):string
- DESCRIPTION: create new method lowercase to write message with [LABEL]. the name of method is the LABEL in lowercase.(see example)
labelstring
- new labelcolor
- one of foreground or background. Default: cyan
- DESCRIPTION: create new method lowercase to write message with [LABEL]. the name of method is the LABEL in lowercase.(see example)
-
message(message:string,color:string):string
- DESCRIPTION: return colored string
message
- message to message to color. Default: nullcolor
- one of foreground or background. Default: cyan
- DESCRIPTION: return colored string
-
info(message:string,stack...): void
- DESCRIPTION: write in cmd a colored message with prefix label "INFO" blue
message
- message to message to color. Default: nullstack
- message to append with label [INFO STACK] ...
- DESCRIPTION: write in cmd a colored message with prefix label "INFO" blue
-
event(message:string,stack...): void
- DESCRIPTION: write in cmd a colored message with prefix label "EVENT" blue
message
- message to message to color. Default: nullstack
- message to append with label [EVENT STACK] ...
- DESCRIPTION: write in cmd a colored message with prefix label "EVENT" blue
-
debug(message:string,stack...): void
- DESCRIPTION: write in cmd a colored message with prefix label "DEBUG" cyan
message
- message to message to color. Default: nullstack
- message to append with label [DEBUG STACK] ...
- DESCRIPTION: write in cmd a colored message with prefix label "DEBUG" cyan
-
command(message:string): void
- DESCRIPTION: write in cmd a colored message with prefix label "COMMAND" yellow
message
- message to message to color. Default: nullstack
- message to append with label [COMMAND STACK] ...
- DESCRIPTION: write in cmd a colored message with prefix label "COMMAND" yellow
-
error(message:string): void
- DESCRIPTION: write in cmd a colored message with prefix label "ERROR" red. Error message have line before and after the message.
message
- message to message to color. Default: nullstack
- message to append with label [ERROR STACK] ...
- DESCRIPTION: write in cmd a colored message with prefix label "ERROR" red. Error message have line before and after the message.
-
printMessage(message:string,color:string):void
- DESCRIPTION: print in cmd the colored message
message
- message to message to color. Default: nullcolor
- one of foreground or background. Default: cyan
- DESCRIPTION: print in cmd the colored message
Extend before 1.1.4
{super;} { super; process;//this lock node process } { this; } { let label = this; this; }
Extend after >=1.1.4
mymessage= new DebugMessage();
mymessage.addLabel("labelCustom","bgyellow");
mymessage.labelcustom("a new custom label");
CHANGE LOG
- 1.1.4 added the dynamic addition to create label
- new label message "info" e "event"
- 1.1.3 fix on documentation