added verbosity

This commit is contained in:
cubedro
2015-06-25 01:59:12 +03:00
parent eaae1ccf11
commit f1ced58587
2 changed files with 69 additions and 31 deletions

View File

@@ -10,7 +10,8 @@ var signs = [
'===',
'>>>',
'xxx',
'=H='
'=H=',
' '
];
var types = [
@@ -20,6 +21,15 @@ var types = [
'his'
];
var verbosity = [
[],
['error', 'warn'],
['info', 'error', 'warn', 'success'],
['info', 'stats', 'sstats', 'error', 'warn', 'success', 'time', 'timeEnd']
];
var ENV_VERBOSITY = process.env.VERBOSITY || 2;
[
{
name: "info",
@@ -31,6 +41,17 @@ var types = [
return [sign, message];
}
},
{
name: "stats",
inherit: 'log',
sign: '=s=',
signColor: chalk.blue,
messageColor: chalk.bold,
formatter: function (sign, message)
{
return [sign, message];
}
},
{
name: "success",
inherit: 'log',
@@ -42,6 +63,17 @@ var types = [
return [sign, message];
}
},
{
name: "sstats",
inherit: 'log',
sign: '=✓=',
signColor: chalk.green,
messageColor: chalk.bold.green,
formatter: function (sign, message)
{
return [sign, message];
}
},
{
name: "warn",
sign: '=!=',
@@ -84,6 +116,8 @@ var types = [
}
].forEach( function (item)
{
var fnName = item.name;
if(item.inherit !== undefined)
console[item.name] = console[item.inherit];
@@ -91,6 +125,9 @@ var types = [
console[item.name] = function ()
{
if(verbosity[ENV_VERBOSITY].indexOf(fnName) === -1)
return false;
var args = Array.prototype.slice.call(arguments);
var sign = item.sign;
var section = 'eth';