updated the module structure

This commit is contained in:
Phil Kunz 2015-09-21 21:50:52 +02:00
parent eea354afd8
commit 21211ec12f
3 changed files with 105 additions and 26 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
.idea/
node_modules

View File

@ -1,20 +1,56 @@
/// <reference path="typings/tsd.d.ts" /> /// <reference path="typings/tsd.d.ts" />
var colors = require("colors"); var colors = require("colors");
var through = require("through2"); var through = require("through2");
var bl = {}; //beautylog object var bl;
bl.errorPrefix = ' Error: '.bgRed.white.bold; bl = {};
bl.successPrefix = ' Success: '.bgGreen.white.bold; /**
module.exports = function (logText, logType) { * 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) {
if (logText === void 0) { logText = 'empty log'; } if (logText === void 0) { logText = 'empty log'; }
if (logType === void 0) { logType = 'normal'; } if (logType === void 0) { logType = 'normal'; }
switch (logType) { try {
case 'normal': switch (logType) {
logText.cyan.bold; case 'normal':
case 'error': logText.cyan.bold;
logText = bl.errorPrefix + logText.red; case 'error':
case 'success': logText = localBl.errorPrefix + logText.red.bold;
logText = bl.successPrefix + logText.cyan; case 'success':
logText = localBl.successPrefix + logText.cyan.bold;
}
console.log(logText);
return true;
}
catch (error) {
console.log(localBl.errorPrefix + 'You seem to have tried logging something strange'.red.bold + error);
return false;
} }
console.log(logText);
return true;
}; };
/**
* 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');
};
module.exports = bl;

View File

@ -2,20 +2,61 @@
var colors = require("colors"); var colors = require("colors");
var through = require("through2"); var through = require("through2");
var bl:any = {}; //beautylog object
bl.errorPrefix = ' Error: '.bgRed.white.bold;
bl.successPrefix = ' Success: '.bgGreen.white.bold;
var bl:any;
bl = {}
module.exports = (logText:string = 'empty log',logType = 'normal') => { /**
switch(logType) { * object to append to all locally used params
case 'normal': * @type {{}}
logText.cyan.bold; */
case 'error': var localBl:any;
logText = bl.errorPrefix + logText.red; localBl = {};
case 'success': localBl.errorPrefix = ' Error: '.bgRed.white.bold;
logText = bl.successPrefix + logText.cyan; localBl.successPrefix = ' Success: '.bgGreen.white.bold;
/**
*
* @param logText
* @param logType
* @returns {boolean}
*/
bl.log = (logText:string = 'empty log',logType:string = 'normal') => {
try {
switch (logType) {
case 'normal':
logText.cyan.bold;
case 'error':
logText = localBl.errorPrefix + logText.red.bold;
case 'success':
logText = localBl.successPrefix + logText.cyan.bold;
}
console.log(logText);
return true;
}
catch(error) {
console.log(localBl.errorPrefix + 'You seem to have tried logging something strange'.red.bold + error);
return false;
} }
console.log(logText);
return true;
}; };
/**
* 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');
}
module.exports = bl;