0.9.6 • Published 8 years ago

caro-console v0.9.6

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

Caro-Console

Build Status

The module for easy-reading node.js console depend on cli-color

Install and Usage

$ npm install caro
var cc = require('caro-console');
cc.log('This is caro-console');

Print nonstop-log

cc.log('This is ', undefined).log('And arr = ', ['caro', 'console']).log('End');

var name = 'caro';
var age = 18;
cc.log('I am %s and %s years old', name, age);
cc.log('I am ', name, ' and ', age, ' years old');

Set your log styles

cc.log.setOddColor('red').setEvenColor('magenta').setStyle('bold', 'underline');
cc.log('This is msg with color-red');
cc.log('This is msg with color-magenta');

Create a new log-function for yourself

cc.createLog('err').setOddColor('red').setEvenColor('magenta');
cc.err('This is Log used for error');

cc.createLog('notice').setColor('cyan').setStyle('bold', 'underline');
cc.notice('This is Log used for notice');

Support print Error

cc.log(new Error('This is Error')); // 'Error: This is Error'

Settings

cc.log.setColor('green');
cc.log.setOddColor('green');
cc.log.setEvenColor('green');
  • setStyle(style...) - set log-style
cc.log.setStyle('bold', 'underline');
  • setLine(length=0) - will print line after each log
cc.log.setLine(40);
cc.log('This is Log with line after');
/*
This is Log with line after
========================================
*/
  • showMe(bool=true) - show stack-info that log placed
/* e.g. in [/caro-console/caro-console.js] */
cc.log.showMe();
cc.log('This is log with stack-info');
/*
Context.<anonymous> (/caro-console/caro-console.coffee:3:4)
This is log with stack-info
*/
  • head(string | function) - show pre-log
var index = 0
cc.log.head(() ->
  var date = new Date();
  return '**Index:' + (++index) + ' - ' + date + '**';
);
cc.log('This is log 1');
cc.log('This is log 2');
/*
**Index:1 - Tue Jun 09 2015 19:00:24 GMT+0800 (CST)**
This is log 1
**Index:2 - Tue Jun 09 2015 19:00:24 GMT+0800 (CST)**
This is log 2
*/
cc.log.head(null)
cc.log('This is log without head')
  • resetAll() - reset all settings
cc.log.resetAll();

Method

  • createLog(logName) - create a new log-function
cc.createLog('err').setColor('red');
cc.err('This is Log used for error');
cc.line(); // ========================================
cc.line(40,false); // ----------------------------------------
  • accept(logName...) - choice which log-function you want to print
cc.log.setColor('white');
cc.createLog('info').setColor('green');
cc.createLog('err').setColor('red');
if (process.env.ENV_VARIABLE === 'production') {
    // only print cc.err and cc.info in console when production
    cc.accept('err', 'info');
} else {
    cc.accept(); // accept all
}
cc.log('This is Log'); // won't print when production
cc.info('This is Info');
cc.err('This is Err'); 
  • showWhere() - print stack-list
/* e.g. in [/caro-console/caro-console.js] */
cc.showWhere();
/*
[ 
    'Context.<anonymous> (/caro-console/caro-console.js:2:4)',
    ...
    ...
]
*/

History

0.9.6

8 years ago

0.9.5

8 years ago

0.9.4

8 years ago

0.9.2

8 years ago

0.9.1

8 years ago

0.9.0

9 years ago

0.8.2

9 years ago

0.8.1

9 years ago

0.7.1

9 years ago

0.7.0

9 years ago

0.5.1

9 years ago

0.5.0

9 years ago

0.4.1

9 years ago

0.4.0

9 years ago

0.3.4

9 years ago

0.3.3

9 years ago

0.3.2

9 years ago

0.3.1

9 years ago

0.3.0

9 years ago

0.2.3

9 years ago

0.2.2

9 years ago

0.2.1

9 years ago

0.2.0

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago