updated the module structure
This commit is contained in:
parent
eea354afd8
commit
21211ec12f
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
.idea/
|
||||
node_modules
|
48
index.js
48
index.js
@ -1,20 +1,56 @@
|
||||
/// <reference path="typings/tsd.d.ts" />
|
||||
var colors = require("colors");
|
||||
var through = require("through2");
|
||||
var bl = {}; //beautylog object
|
||||
bl.errorPrefix = ' Error: '.bgRed.white.bold;
|
||||
bl.successPrefix = ' Success: '.bgGreen.white.bold;
|
||||
module.exports = function (logText, logType) {
|
||||
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) {
|
||||
if (logText === void 0) { logText = 'empty log'; }
|
||||
if (logType === void 0) { logType = 'normal'; }
|
||||
try {
|
||||
switch (logType) {
|
||||
case 'normal':
|
||||
logText.cyan.bold;
|
||||
case 'error':
|
||||
logText = bl.errorPrefix + logText.red;
|
||||
logText = localBl.errorPrefix + logText.red.bold;
|
||||
case 'success':
|
||||
logText = bl.successPrefix + logText.cyan;
|
||||
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;
|
||||
}
|
||||
};
|
||||
/**
|
||||
* 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;
|
||||
|
53
ts/index.ts
53
ts/index.ts
@ -2,20 +2,61 @@
|
||||
var colors = require("colors");
|
||||
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') => {
|
||||
/**
|
||||
* object to append to all locally used params
|
||||
* @type {{}}
|
||||
*/
|
||||
var localBl:any;
|
||||
localBl = {};
|
||||
localBl.errorPrefix = ' Error: '.bgRed.white.bold;
|
||||
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 = bl.errorPrefix + logText.red;
|
||||
logText = localBl.errorPrefix + logText.red.bold;
|
||||
case 'success':
|
||||
logText = bl.successPrefix + logText.cyan;
|
||||
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;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
Loading…
Reference in New Issue
Block a user