2015-09-26 17:34:01 +00:00
|
|
|
/// <reference path="./typings/tsd.d.ts" />
|
2015-09-20 19:45:37 +00:00
|
|
|
var colors = require("colors");
|
|
|
|
var through = require("through2");
|
2015-09-21 19:50:52 +00:00
|
|
|
var bl;
|
|
|
|
bl = {};
|
|
|
|
/**
|
|
|
|
* object to append to all locally used params
|
|
|
|
* @type {{}}
|
|
|
|
*/
|
|
|
|
var localBl;
|
|
|
|
localBl = {};
|
|
|
|
localBl.errorPrefix = ' Error: '.bgRed.white.bold;
|
|
|
|
localBl.successPrefix = ' Success: '.bgGreen.white.bold;
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param logText
|
|
|
|
* @param logType
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
bl.log = function (logText, logType) {
|
2015-09-20 19:45:37 +00:00
|
|
|
if (logText === void 0) { logText = 'empty log'; }
|
|
|
|
if (logType === void 0) { logType = 'normal'; }
|
2015-09-21 19:50:52 +00:00
|
|
|
try {
|
|
|
|
switch (logType) {
|
|
|
|
case 'normal':
|
|
|
|
logText.cyan.bold;
|
2015-09-26 17:34:01 +00:00
|
|
|
break;
|
2015-09-21 19:50:52 +00:00
|
|
|
case 'error':
|
|
|
|
logText = localBl.errorPrefix + logText.red.bold;
|
2015-09-26 17:34:01 +00:00
|
|
|
break;
|
2015-09-21 19:50:52 +00:00
|
|
|
case 'success':
|
|
|
|
logText = localBl.successPrefix + logText.cyan.bold;
|
2015-09-26 17:34:01 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
logText.blue.bold;
|
|
|
|
console.log(('unknown logType for "' + logText + '"').red.bold);
|
2015-09-21 19:50:52 +00:00
|
|
|
}
|
|
|
|
console.log(logText);
|
|
|
|
return true;
|
2015-09-20 19:45:37 +00:00
|
|
|
}
|
2015-09-21 19:50:52 +00:00
|
|
|
catch (error) {
|
|
|
|
console.log(localBl.errorPrefix + 'You seem to have tried logging something strange'.red.bold + error);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
/**
|
|
|
|
* logs an error to console
|
|
|
|
* @param logText
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
bl.error = function (logText) {
|
|
|
|
return bl.log(logText, 'error');
|
|
|
|
};
|
|
|
|
/**
|
|
|
|
* logs a success to console
|
|
|
|
* @param logText string to log as error
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
bl.success = function (logText) {
|
|
|
|
return bl.log(logText, 'success');
|
2015-09-20 17:21:29 +00:00
|
|
|
};
|
2015-09-21 19:50:52 +00:00
|
|
|
module.exports = bl;
|