cout
A basic JavaScript console utility with sprintf and colors support.
Install
sudo npm install --save cout
Usage
var cout = //sprintf(..., ...) or use cout.kawari(..., ...)sprintf = coutkawari; //configure (optional)cout; //will print on a single line (no color);//will print on newlines (can be changed through cout.config()) (no color); //will print with new line color (see themes for color/level); //you can customize the background and styles (see styles); //sprintf from the top level (to keep things simple internally);
Methods
end()
endl()
warn()
data()
debug()
error()
help()
info()
input()
prompt()
silly()
verbose()
Config
The following are the default values but can be changed
//configurecout; //specify which level (Array or String) to display //by default '*' means display all levels //if you pass a level array and want to display end() and endl() //just add 'normal' to the array. cout: '*' //default theme/colors/levels theme: data: 'grey' debug: 'blue' error: 'red' help: 'cyan' info: 'green' input: 'grey' prompt: 'grey' silly: 'rainbow' verbose: 'cyan' warn: 'yellow' //used for pretty printing json/plain objects json: space: 2 //specify the number of new lines. newline: '\n'
Styles
Usage
//use style keystyle: ...
- reset
- bold
- dim
- italic
- underline
- inverse
- hidden
- strikethrough
Background color
Usage
//use bg keybg: ...
- black
- red
- green
- yellow
- blue
- magenta
- cyan
- white
Time stamp
cout uses Moment.js for time stamps. See Moment.js' docs for formatting and locales.
Usage
Default: false
Acceptable types: Boolean, Plain Object
//booleantrue or false timestamp: //format the time format:'dddd' //change the locale locale: 'ja' //spacing: can be tabs or spaces space: '\n'
Changlog
0.0.1
- Initial commit
0.0.2
- Cleaned code and removed confusing debug statement.
- Updated readme
0.0.3
- Updated readme
- Removed unnecessary comments.
0.0.4
- Added node_modules to .gitignore
0.0.5
- Added boolean support. You can now set
{cout:...}
totrue
orfalse
.
0.0.6
- Added time stamp support. You can pass a Boolean or configure the time stamp's locale and format by passing a plain Object.
- Added 'normal' level for end() and endl() when using an array with levels.