version update
This commit is contained in:
parent
8035a6b17d
commit
8e74e71911
265
index.js
265
index.js
@ -1,111 +1,160 @@
|
|||||||
|
/// <reference path="./index.ts" />
|
||||||
|
var BeautylogOS;
|
||||||
|
(function (BeautylogOS) {
|
||||||
|
function init() {
|
||||||
|
var colors = require("colors");
|
||||||
|
var clc = require("cli-color");
|
||||||
|
var beautylogOS = {};
|
||||||
|
/**
|
||||||
|
* object to append to all locally used params
|
||||||
|
* @type {{}}
|
||||||
|
*/
|
||||||
|
var localBl;
|
||||||
|
localBl = {};
|
||||||
|
localBl.dirPrefix = clc.bgXterm(39).xterm(231).bold(' DIR ') + ' ';
|
||||||
|
localBl.errorPrefix = ' Error: '.bgRed.white.bold + ' ';
|
||||||
|
localBl.infoPrefix = clc.bgXterm(198).xterm(231).bold(' INFO ') + ' ';
|
||||||
|
localBl.normalPrefix = ' Log: '.bgCyan.white.bold + ' ';
|
||||||
|
localBl.okPrefix = ' '.bgGreen + ' OK! '.bgBlack.green.bold + ' ';
|
||||||
|
localBl.successPrefix = ' Success: '.bgGreen.white.bold + ' ';
|
||||||
|
localBl.warnPrefix = ' '.bgYellow + ' Warn: '.bgBlack.yellow.bold + ' ';
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param logText
|
||||||
|
* @param logType
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
beautylogOS.log = function (logText, logType) {
|
||||||
|
if (logText === void 0) { logText = 'empty log'; }
|
||||||
|
if (logType === void 0) { logType = 'normal'; }
|
||||||
|
try {
|
||||||
|
switch (logType) {
|
||||||
|
case 'dir':
|
||||||
|
logText = localBl.dirPrefix + clc.xterm(26)(logText);
|
||||||
|
break;
|
||||||
|
case 'error':
|
||||||
|
logText = localBl.errorPrefix + logText.red.bold;
|
||||||
|
break;
|
||||||
|
case 'info':
|
||||||
|
logText = localBl.infoPrefix + clc.xterm(198)(logText);
|
||||||
|
break;
|
||||||
|
case 'normal':
|
||||||
|
logText = localBl.normalPrefix + logText.cyan.bold;
|
||||||
|
break;
|
||||||
|
case 'ok':
|
||||||
|
logText = localBl.okPrefix + logText.bold;
|
||||||
|
break;
|
||||||
|
case 'success':
|
||||||
|
logText = localBl.successPrefix + logText.green.bold;
|
||||||
|
break;
|
||||||
|
case 'warn':
|
||||||
|
logText = localBl.warnPrefix + logText.bold;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
logText.blue.bold;
|
||||||
|
console.log(('unknown logType for "' + logText + '"').red.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 directory to console
|
||||||
|
* @param logText
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
beautylogOS.dir = function (logText) {
|
||||||
|
return beautylogOS.log(logText, 'dir');
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* logs an error to console
|
||||||
|
* @param logText
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
beautylogOS.error = function (logText) {
|
||||||
|
return beautylogOS.log(logText, 'error');
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* logs an info to console
|
||||||
|
* @param logText
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
beautylogOS.info = function (logText) {
|
||||||
|
return beautylogOS.log(logText, 'info');
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* logs an 'OK!' message to console
|
||||||
|
* @param logText
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
beautylogOS.ok = function (logText) {
|
||||||
|
return beautylogOS.log(logText, 'ok');
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* logs a success to console
|
||||||
|
* @param logText string to log as error
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
beautylogOS.success = function (logText) {
|
||||||
|
return beautylogOS.log(logText, 'success');
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* logs a 'warn:' message to console
|
||||||
|
* @param logText string to log as error
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
beautylogOS.warn = function (logText) {
|
||||||
|
return beautylogOS.log(logText, 'warn');
|
||||||
|
};
|
||||||
|
return beautylogOS;
|
||||||
|
}
|
||||||
|
BeautylogOS.init = init;
|
||||||
|
})(BeautylogOS || (BeautylogOS = {}));
|
||||||
|
/// <reference path="./index.ts" />
|
||||||
|
var BeautylogBrowser;
|
||||||
|
(function (BeautylogBrowser) {
|
||||||
|
function init() {
|
||||||
|
var beautylogBrowser = {};
|
||||||
|
return beautylogBrowser;
|
||||||
|
beautylogBrowser.log = function (message) {
|
||||||
|
console.log('%c Log: %c ' + message, "background:#42A5F5;color:#ffffff", "color:#42A5F5;");
|
||||||
|
};
|
||||||
|
beautylogBrowser.info = function (message) {
|
||||||
|
console.log('%c Info: %c ' + message, 'background:#EC407A;color:#ffffff;', 'color:#EC407A;');
|
||||||
|
};
|
||||||
|
beautylogBrowser.ok = function (message) {
|
||||||
|
console.log('%c OK: %c ' + message, "background:#000000;color:#8BC34A;", "color:#000000;");
|
||||||
|
};
|
||||||
|
beautylogBrowser.success = function (message) {
|
||||||
|
console.log('%c Success: %c ' + message, "background:#8BC34A;color:#ffffff;", "color:#8BC34A;");
|
||||||
|
};
|
||||||
|
beautylogBrowser.warn = function (message) {
|
||||||
|
console.log('%c Warn: %c ' + message, "background:#000000;color:#FB8C00;", "color:#000000;");
|
||||||
|
};
|
||||||
|
}
|
||||||
|
BeautylogBrowser.init = init;
|
||||||
|
})(BeautylogBrowser || (BeautylogBrowser = {}));
|
||||||
/// <reference path="./typings/tsd.d.ts" />
|
/// <reference path="./typings/tsd.d.ts" />
|
||||||
var colors = require("colors");
|
/// <reference path="./console.os.ts" />
|
||||||
var clc = require("cli-color");
|
/// <reference path="./console.browser.ts" />
|
||||||
var bl;
|
var beautylog = function (logPlatform) {
|
||||||
bl = {};
|
if (logPlatform === void 0) { logPlatform = "os"; }
|
||||||
/**
|
switch (logPlatform) {
|
||||||
* object to append to all locally used params
|
case "os":
|
||||||
* @type {{}}
|
var beautylogOs = BeautylogOS.init();
|
||||||
*/
|
return beautylogOs;
|
||||||
var localBl;
|
break;
|
||||||
localBl = {};
|
case "browser":
|
||||||
localBl.dirPrefix = clc.bgXterm(39).xterm(231).bold(' DIR ') + ' ';
|
var beautylogBrowser = BeautylogBrowser.init();
|
||||||
localBl.errorPrefix = ' Error: '.bgRed.white.bold + ' ';
|
return beautylogBrowser;
|
||||||
localBl.infoPrefix = clc.bgXterm(198).xterm(231).bold(' INFO ') + ' ';
|
break;
|
||||||
localBl.normalPrefix = ' Log: '.bgCyan.white.bold + ' ';
|
default:
|
||||||
localBl.okPrefix = ' '.bgGreen + ' OK! '.bgBlack.green.bold + ' ';
|
console.log("something is strage about the way you required beautylog");
|
||||||
localBl.successPrefix = ' Success: '.bgGreen.white.bold + ' ';
|
break;
|
||||||
localBl.warnPrefix = ' '.bgYellow + ' Warn: '.bgBlack.yellow.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 'dir':
|
|
||||||
logText = localBl.dirPrefix + clc.xterm(26)(logText);
|
|
||||||
break;
|
|
||||||
case 'error':
|
|
||||||
logText = localBl.errorPrefix + logText.red.bold;
|
|
||||||
break;
|
|
||||||
case 'info':
|
|
||||||
logText = localBl.infoPrefix + clc.xterm(198)(logText);
|
|
||||||
break;
|
|
||||||
case 'normal':
|
|
||||||
logText = localBl.normalPrefix + logText.cyan.bold;
|
|
||||||
break;
|
|
||||||
case 'ok':
|
|
||||||
logText = localBl.okPrefix + logText.bold;
|
|
||||||
break;
|
|
||||||
case 'success':
|
|
||||||
logText = localBl.successPrefix + logText.green.bold;
|
|
||||||
break;
|
|
||||||
case 'warn':
|
|
||||||
logText = localBl.warnPrefix + logText.bold;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
logText.blue.bold;
|
|
||||||
console.log(('unknown logType for "' + logText + '"').red.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;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
/**
|
module.exports = beautylog;
|
||||||
* logs an directory to console
|
|
||||||
* @param logText
|
|
||||||
* @returns {boolean}
|
|
||||||
*/
|
|
||||||
bl.dir = function (logText) {
|
|
||||||
return bl.log(logText, 'dir');
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* logs an error to console
|
|
||||||
* @param logText
|
|
||||||
* @returns {boolean}
|
|
||||||
*/
|
|
||||||
bl.error = function (logText) {
|
|
||||||
return bl.log(logText, 'error');
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* logs an info to console
|
|
||||||
* @param logText
|
|
||||||
* @returns {boolean}
|
|
||||||
*/
|
|
||||||
bl.info = function (logText) {
|
|
||||||
return bl.log(logText, 'info');
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* logs an 'OK!' message to console
|
|
||||||
* @param logText
|
|
||||||
* @returns {boolean}
|
|
||||||
*/
|
|
||||||
bl.ok = function (logText) {
|
|
||||||
return bl.log(logText, 'ok');
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* logs a success to console
|
|
||||||
* @param logText string to log as error
|
|
||||||
* @returns {boolean}
|
|
||||||
*/
|
|
||||||
bl.success = function (logText) {
|
|
||||||
return bl.log(logText, 'success');
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* logs a 'warn:' message to console
|
|
||||||
* @param logText string to log as error
|
|
||||||
* @returns {boolean}
|
|
||||||
*/
|
|
||||||
bl.warn = function (logText) {
|
|
||||||
return bl.log(logText, 'warn');
|
|
||||||
};
|
|
||||||
module.exports = bl;
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "beautylog",
|
"name": "beautylog",
|
||||||
"version": "0.0.15",
|
"version": "1.0.0",
|
||||||
"description": "beautiful logging",
|
"description": "beautiful logging",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
31
test.js
31
test.js
@ -1,23 +1,24 @@
|
|||||||
/// <reference path="./typings/tsd.d.ts" />
|
/// <reference path="./typings/tsd.d.ts" />
|
||||||
var beautyLog = require('./index.js');
|
var beautyLogOs = require('./index.js')("os");
|
||||||
|
var beautyLogBrowser = require("./index.js")("browser");
|
||||||
console.log('*** start test ***');
|
console.log('*** start test ***');
|
||||||
console.log('');
|
console.log('');
|
||||||
console.log('declarative function calls:');
|
console.log('declarative function calls:');
|
||||||
beautyLog.log('beautylog.log(), with normal logText, without logType');
|
beautyLogOs.log('beautylog.log(), with normal logText, without logType');
|
||||||
beautyLog.dir('beautylog.dir(), with normal logText, without logType');
|
beautyLogOs.dir('beautylog.dir(), with normal logText, without logType');
|
||||||
beautyLog.error('beautylog.error(), with normal logText, without logType');
|
beautyLogOs.error('beautylog.error(), with normal logText, without logType');
|
||||||
beautyLog.info('beautylog.dir(), with normal logText, without logType');
|
beautyLogOs.info('beautylog.dir(), with normal logText, without logType');
|
||||||
beautyLog.ok('beautylog.ok(), with normal logText, without logType');
|
beautyLogOs.ok('beautylog.ok(), with normal logText, without logType');
|
||||||
beautyLog.success('beautylog.success(), with normal logText, without logType');
|
beautyLogOs.success('beautylog.success(), with normal logText, without logType');
|
||||||
beautyLog.warn('beautylog.warn(), with normal logText, without logType');
|
beautyLogOs.warn('beautylog.warn(), with normal logText, without logType');
|
||||||
console.log('');
|
console.log('');
|
||||||
console.log('logType String:');
|
console.log('logType String:');
|
||||||
beautyLog.log('beautylog.log(), with normal logText, without logType');
|
beautyLogOs.log('beautylog.log(), with normal logText, without logType');
|
||||||
beautyLog.log('beautylog.log(), with normal logText, with logType "dir"', 'dir');
|
beautyLogOs.log('beautylog.log(), with normal logText, with logType "dir"', 'dir');
|
||||||
beautyLog.log('beautylog.log(), with normal logText, with logType "error"', 'error');
|
beautyLogOs.log('beautylog.log(), with normal logText, with logType "error"', 'error');
|
||||||
beautyLog.log('beautylog.log(), with normal logText, with logType "info"', 'info');
|
beautyLogOs.log('beautylog.log(), with normal logText, with logType "info"', 'info');
|
||||||
beautyLog.log('beautylog.log(), with normal logText, with logType "ok"', 'ok');
|
beautyLogOs.log('beautylog.log(), with normal logText, with logType "ok"', 'ok');
|
||||||
beautyLog.log('beautylog.log(), with normal logText, with logType "success"', 'success');
|
beautyLogOs.log('beautylog.log(), with normal logText, with logType "success"', 'success');
|
||||||
beautyLog.log('beautylog.log(), with normal logText, with logType "warn"', 'warn');
|
beautyLogOs.log('beautylog.log(), with normal logText, with logType "warn"', 'warn');
|
||||||
console.log('');
|
console.log('');
|
||||||
console.log('*** end test ***');
|
console.log('*** end test ***');
|
||||||
|
25
ts/console.browser.js
Normal file
25
ts/console.browser.js
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
/// <reference path="./index.ts" />
|
||||||
|
var BeautylogBrowser;
|
||||||
|
(function (BeautylogBrowser) {
|
||||||
|
function init() {
|
||||||
|
var beautylogBrowser = {};
|
||||||
|
return beautylogBrowser;
|
||||||
|
beautylogBrowser.log = function (message) {
|
||||||
|
console.log('%c Log: %c ' + message, "background:#42A5F5;color:#ffffff", "color:#42A5F5;");
|
||||||
|
};
|
||||||
|
beautylogBrowser.info = function (message) {
|
||||||
|
console.log('%c Info: %c ' + message, 'background:#EC407A;color:#ffffff;', 'color:#EC407A;');
|
||||||
|
};
|
||||||
|
beautylogBrowser.ok = function (message) {
|
||||||
|
console.log('%c OK: %c ' + message, "background:#000000;color:#8BC34A;", "color:#000000;");
|
||||||
|
};
|
||||||
|
beautylogBrowser.success = function (message) {
|
||||||
|
console.log('%c Success: %c ' + message, "background:#8BC34A;color:#ffffff;", "color:#8BC34A;");
|
||||||
|
};
|
||||||
|
beautylogBrowser.warn = function (message) {
|
||||||
|
console.log('%c Warn: %c ' + message, "background:#000000;color:#FB8C00;", "color:#000000;");
|
||||||
|
};
|
||||||
|
}
|
||||||
|
BeautylogBrowser.init = init;
|
||||||
|
})(BeautylogBrowser || (BeautylogBrowser = {}));
|
||||||
|
//# sourceMappingURL=console.browser.js.map
|
1
ts/console.browser.js.map
Normal file
1
ts/console.browser.js.map
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"console.browser.js","sourceRoot":"","sources":["console.browser.ts"],"names":["BeautylogBrowser","BeautylogBrowser.init"],"mappings":"AAAA,mCAAmC;AACnC,IAAO,gBAAgB,CAoBtB;AApBD,WAAO,gBAAgB,EAAC,CAAC;IACrBA;QACIC,IAAIA,gBAAgBA,GAAOA,EAAEA,CAACA;QAC9BA,MAAMA,CAACA,gBAAgBA,CAACA;QACxBA,gBAAgBA,CAACA,GAAGA,GAAGA,UAASA,OAAOA;YACnC,OAAO,CAAC,GAAG,CAAC,aAAa,GAAG,OAAO,EAAC,kCAAkC,EAAC,gBAAgB,CAAC,CAAC;QAC7F,CAAC,CAACA;QACFA,gBAAgBA,CAACA,IAAIA,GAAGA,UAASA,OAAOA;YACpC,OAAO,CAAC,GAAG,CAAC,cAAc,GAAG,OAAO,EAAC,mCAAmC,EAAC,gBAAgB,CAAC,CAAC;QAC/F,CAAC,CAACA;QACFA,gBAAgBA,CAACA,EAAEA,GAAGA,UAASA,OAAOA;YAClC,OAAO,CAAC,GAAG,CAAC,YAAY,GAAG,OAAO,EAAC,mCAAmC,EAAC,gBAAgB,CAAC,CAAC;QAC7F,CAAC,CAACA;QACFA,gBAAgBA,CAACA,OAAOA,GAAGA,UAASA,OAAOA;YACvC,OAAO,CAAC,GAAG,CAAC,iBAAiB,GAAG,OAAO,EAAC,mCAAmC,EAAC,gBAAgB,CAAC,CAAC;QAClG,CAAC,CAACA;QACFA,gBAAgBA,CAACA,IAAIA,GAAGA,UAASA,OAAOA;YACpC,OAAO,CAAC,GAAG,CAAC,cAAc,GAAG,OAAO,EAAC,mCAAmC,EAAC,gBAAgB,CAAC,CAAC;QAC/F,CAAC,CAACA;IACNA,CAACA;IAlBeD,qBAAIA,OAkBnBA,CAAAA;AACLA,CAACA,EApBM,gBAAgB,KAAhB,gBAAgB,QAoBtB"}
|
22
ts/console.browser.ts
Normal file
22
ts/console.browser.ts
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
/// <reference path="./index.ts" />
|
||||||
|
module BeautylogBrowser {
|
||||||
|
export function init() {
|
||||||
|
var beautylogBrowser:any = {};
|
||||||
|
return beautylogBrowser;
|
||||||
|
beautylogBrowser.log = function(message){
|
||||||
|
console.log('%c Log: %c ' + message,"background:#42A5F5;color:#ffffff","color:#42A5F5;");
|
||||||
|
};
|
||||||
|
beautylogBrowser.info = function(message){
|
||||||
|
console.log('%c Info: %c ' + message,'background:#EC407A;color:#ffffff;','color:#EC407A;');
|
||||||
|
};
|
||||||
|
beautylogBrowser.ok = function(message){
|
||||||
|
console.log('%c OK: %c ' + message,"background:#000000;color:#8BC34A;","color:#000000;");
|
||||||
|
};
|
||||||
|
beautylogBrowser.success = function(message){
|
||||||
|
console.log('%c Success: %c ' + message,"background:#8BC34A;color:#ffffff;","color:#8BC34A;");
|
||||||
|
};
|
||||||
|
beautylogBrowser.warn = function(message){
|
||||||
|
console.log('%c Warn: %c ' + message,"background:#000000;color:#FB8C00;","color:#000000;");
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
117
ts/console.os.js
Normal file
117
ts/console.os.js
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
/// <reference path="./index.ts" />
|
||||||
|
var BeautylogOS;
|
||||||
|
(function (BeautylogOS) {
|
||||||
|
function init() {
|
||||||
|
var colors = require("colors");
|
||||||
|
var clc = require("cli-color");
|
||||||
|
var beautylogOS = {};
|
||||||
|
/**
|
||||||
|
* object to append to all locally used params
|
||||||
|
* @type {{}}
|
||||||
|
*/
|
||||||
|
var localBl;
|
||||||
|
localBl = {};
|
||||||
|
localBl.dirPrefix = clc.bgXterm(39).xterm(231).bold(' DIR ') + ' ';
|
||||||
|
localBl.errorPrefix = ' Error: '.bgRed.white.bold + ' ';
|
||||||
|
localBl.infoPrefix = clc.bgXterm(198).xterm(231).bold(' INFO ') + ' ';
|
||||||
|
localBl.normalPrefix = ' Log: '.bgCyan.white.bold + ' ';
|
||||||
|
localBl.okPrefix = ' '.bgGreen + ' OK! '.bgBlack.green.bold + ' ';
|
||||||
|
localBl.successPrefix = ' Success: '.bgGreen.white.bold + ' ';
|
||||||
|
localBl.warnPrefix = ' '.bgYellow + ' Warn: '.bgBlack.yellow.bold + ' ';
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param logText
|
||||||
|
* @param logType
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
beautylogOS.log = function (logText, logType) {
|
||||||
|
if (logText === void 0) { logText = 'empty log'; }
|
||||||
|
if (logType === void 0) { logType = 'normal'; }
|
||||||
|
try {
|
||||||
|
switch (logType) {
|
||||||
|
case 'dir':
|
||||||
|
logText = localBl.dirPrefix + clc.xterm(26)(logText);
|
||||||
|
break;
|
||||||
|
case 'error':
|
||||||
|
logText = localBl.errorPrefix + logText.red.bold;
|
||||||
|
break;
|
||||||
|
case 'info':
|
||||||
|
logText = localBl.infoPrefix + clc.xterm(198)(logText);
|
||||||
|
break;
|
||||||
|
case 'normal':
|
||||||
|
logText = localBl.normalPrefix + logText.cyan.bold;
|
||||||
|
break;
|
||||||
|
case 'ok':
|
||||||
|
logText = localBl.okPrefix + logText.bold;
|
||||||
|
break;
|
||||||
|
case 'success':
|
||||||
|
logText = localBl.successPrefix + logText.green.bold;
|
||||||
|
break;
|
||||||
|
case 'warn':
|
||||||
|
logText = localBl.warnPrefix + logText.bold;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
logText.blue.bold;
|
||||||
|
console.log(('unknown logType for "' + logText + '"').red.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 directory to console
|
||||||
|
* @param logText
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
beautylogOS.dir = function (logText) {
|
||||||
|
return beautylogOS.log(logText, 'dir');
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* logs an error to console
|
||||||
|
* @param logText
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
beautylogOS.error = function (logText) {
|
||||||
|
return beautylogOS.log(logText, 'error');
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* logs an info to console
|
||||||
|
* @param logText
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
beautylogOS.info = function (logText) {
|
||||||
|
return beautylogOS.log(logText, 'info');
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* logs an 'OK!' message to console
|
||||||
|
* @param logText
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
beautylogOS.ok = function (logText) {
|
||||||
|
return beautylogOS.log(logText, 'ok');
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* logs a success to console
|
||||||
|
* @param logText string to log as error
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
beautylogOS.success = function (logText) {
|
||||||
|
return beautylogOS.log(logText, 'success');
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* logs a 'warn:' message to console
|
||||||
|
* @param logText string to log as error
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
beautylogOS.warn = function (logText) {
|
||||||
|
return beautylogOS.log(logText, 'warn');
|
||||||
|
};
|
||||||
|
return beautylogOS;
|
||||||
|
}
|
||||||
|
BeautylogOS.init = init;
|
||||||
|
})(BeautylogOS || (BeautylogOS = {}));
|
||||||
|
//# sourceMappingURL=console.os.js.map
|
1
ts/console.os.js.map
Normal file
1
ts/console.os.js.map
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"console.os.js","sourceRoot":"","sources":["console.os.ts"],"names":["BeautylogOS","BeautylogOS.init"],"mappings":"AAAA,mCAAmC;AACnC,IAAO,WAAW,CA0HjB;AA1HD,WAAO,WAAW,EAAC,CAAC;IAChBA;QACIC,IAAIA,MAAMA,GAAGA,OAAOA,CAACA,QAAQA,CAACA,CAACA;QAC/BA,IAAIA,GAAGA,GAAGA,OAAOA,CAACA,WAAWA,CAACA,CAACA;QAE/BA,IAAIA,WAAWA,GAAOA,EAAEA,CAACA;QACzBA;;;WAGGA;QACHA,IAAIA,OAAWA,CAACA;QAChBA,OAAOA,GAAGA,EAAEA,CAACA;QACbA,OAAOA,CAACA,SAASA,GAAGA,GAAGA,CAACA,OAAOA,CAACA,EAAEA,CAACA,CAACA,KAAKA,CAACA,GAAGA,CAACA,CAACA,IAAIA,CAACA,OAAOA,CAACA,GAAGA,GAAGA,CAACA;QACnEA,OAAOA,CAACA,WAAWA,GAAGA,UAAUA,CAACA,KAAKA,CAACA,KAAKA,CAACA,IAAIA,GAAGA,GAAGA,CAACA;QACxDA,OAAOA,CAACA,UAAUA,GAAGA,GAAGA,CAACA,OAAOA,CAACA,GAAGA,CAACA,CAACA,KAAKA,CAACA,GAAGA,CAACA,CAACA,IAAIA,CAACA,QAAQA,CAACA,GAAGA,GAAGA,CAACA;QACtEA,OAAOA,CAACA,YAAYA,GAAGA,QAAQA,CAACA,MAAMA,CAACA,KAAKA,CAACA,IAAIA,GAAGA,GAAGA,CAACA;QACxDA,OAAOA,CAACA,QAAQA,GAAGA,GAAGA,CAACA,OAAOA,GAAGA,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QAC5C,CAAC,CAACA;QAEFA;;;;WAIGA;QACHA,WAAWA,CAACA,EAAEA,GAAGA,UAASA,OAAOA;YAC7B,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QAC1C,CAAC,CAACA;QAEFA;;;;WAIGA;QACHA,WAAWA,CAACA,OAAOA,GAAGA,UAASA,OAAOA;YAClC,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;QAC/C,CAAC,CAAAA;QAEDA;;;;WAIGA;QACHA,WAAWA,CAACA,IAAIA,GAAGA,UAASA,OAAOA;YAC/B,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAC5C,CAAC,CAAAA;QAEDA,MAAMA,CAACA,WAAWA,CAACA;IACvBA,CAACA;IAxHeD,gBAAIA,OAwHnBA,CAAAA;AACLA,CAACA,EA1HM,WAAW,KAAX,WAAW,QA0HjB"}
|
124
ts/console.os.ts
Normal file
124
ts/console.os.ts
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
/// <reference path="./index.ts" />
|
||||||
|
module BeautylogOS {
|
||||||
|
export function init() {
|
||||||
|
var colors = require("colors");
|
||||||
|
var clc = require("cli-color");
|
||||||
|
|
||||||
|
var beautylogOS:any = {};
|
||||||
|
/**
|
||||||
|
* object to append to all locally used params
|
||||||
|
* @type {{}}
|
||||||
|
*/
|
||||||
|
var localBl:any;
|
||||||
|
localBl = {};
|
||||||
|
localBl.dirPrefix = clc.bgXterm(39).xterm(231).bold(' DIR ') + ' ';
|
||||||
|
localBl.errorPrefix = ' Error: '.bgRed.white.bold + ' ';
|
||||||
|
localBl.infoPrefix = clc.bgXterm(198).xterm(231).bold(' INFO ') + ' ';
|
||||||
|
localBl.normalPrefix = ' Log: '.bgCyan.white.bold + ' ';
|
||||||
|
localBl.okPrefix = ' '.bgGreen + ' OK! '.bgBlack.green.bold + ' ';
|
||||||
|
localBl.successPrefix = ' Success: '.bgGreen.white.bold + ' ';
|
||||||
|
localBl.warnPrefix = ' '.bgYellow + ' Warn: '.bgBlack.yellow.bold + ' ';
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param logText
|
||||||
|
* @param logType
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
beautylogOS.log = (logText:string = 'empty log', logType:string = 'normal') => {
|
||||||
|
try {
|
||||||
|
switch (logType) {
|
||||||
|
case 'dir':
|
||||||
|
logText = localBl.dirPrefix + clc.xterm(26)(logText);
|
||||||
|
break;
|
||||||
|
case 'error':
|
||||||
|
logText = localBl.errorPrefix + logText.red.bold;
|
||||||
|
break;
|
||||||
|
case 'info':
|
||||||
|
logText = localBl.infoPrefix + clc.xterm(198)(logText);
|
||||||
|
break;
|
||||||
|
case 'normal':
|
||||||
|
logText = localBl.normalPrefix + logText.cyan.bold;
|
||||||
|
break;
|
||||||
|
case 'ok':
|
||||||
|
logText = localBl.okPrefix + logText.bold;
|
||||||
|
break;
|
||||||
|
case 'success':
|
||||||
|
logText = localBl.successPrefix + logText.green.bold;
|
||||||
|
break;
|
||||||
|
case 'warn':
|
||||||
|
logText = localBl.warnPrefix + logText.bold;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
logText.blue.bold;
|
||||||
|
console.log(('unknown logType for "' + logText + '"').red.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 directory to console
|
||||||
|
* @param logText
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
beautylogOS.dir = function(logText) {
|
||||||
|
return beautylogOS.log(logText, 'dir');
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* logs an error to console
|
||||||
|
* @param logText
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
beautylogOS.error = function(logText) {
|
||||||
|
return beautylogOS.log(logText, 'error');
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* logs an info to console
|
||||||
|
* @param logText
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
beautylogOS.info = function(logText) {
|
||||||
|
return beautylogOS.log(logText, 'info');
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* logs an 'OK!' message to console
|
||||||
|
* @param logText
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
beautylogOS.ok = function(logText) {
|
||||||
|
return beautylogOS.log(logText, 'ok');
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* logs a success to console
|
||||||
|
* @param logText string to log as error
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
beautylogOS.success = function(logText) {
|
||||||
|
return beautylogOS.log(logText, 'success');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* logs a 'warn:' message to console
|
||||||
|
* @param logText string to log as error
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
beautylogOS.warn = function(logText) {
|
||||||
|
return beautylogOS.log(logText, 'warn');
|
||||||
|
}
|
||||||
|
|
||||||
|
return beautylogOS;
|
||||||
|
}
|
||||||
|
}
|
125
ts/index.js
125
ts/index.js
@ -1,112 +1,21 @@
|
|||||||
/// <reference path="./typings/tsd.d.ts" />
|
/// <reference path="./typings/tsd.d.ts" />
|
||||||
var colors = require("colors");
|
/// <reference path="./console.os.ts" />
|
||||||
var clc = require("cli-color");
|
/// <reference path="./console.browser.ts" />
|
||||||
var bl;
|
var beautylog = function (logPlatform) {
|
||||||
bl = {};
|
if (logPlatform === void 0) { logPlatform = "os"; }
|
||||||
/**
|
switch (logPlatform) {
|
||||||
* object to append to all locally used params
|
case "os":
|
||||||
* @type {{}}
|
var beautylogOs = BeautylogOS.init();
|
||||||
*/
|
return beautylogOs;
|
||||||
var localBl;
|
break;
|
||||||
localBl = {};
|
case "browser":
|
||||||
localBl.dirPrefix = clc.bgXterm(39).xterm(231).bold(' DIR ') + ' ';
|
var beautylogBrowser = BeautylogBrowser.init();
|
||||||
localBl.errorPrefix = ' Error: '.bgRed.white.bold + ' ';
|
return beautylogBrowser;
|
||||||
localBl.infoPrefix = clc.bgXterm(198).xterm(231).bold(' INFO ') + ' ';
|
break;
|
||||||
localBl.normalPrefix = ' Log: '.bgCyan.white.bold + ' ';
|
default:
|
||||||
localBl.okPrefix = ' '.bgGreen + ' OK! '.bgBlack.green.bold + ' ';
|
console.log("something is strage about the way you required beautylog");
|
||||||
localBl.successPrefix = ' Success: '.bgGreen.white.bold + ' ';
|
break;
|
||||||
localBl.warnPrefix = ' '.bgYellow + ' Warn: '.bgBlack.yellow.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 'dir':
|
|
||||||
logText = localBl.dirPrefix + clc.xterm(26)(logText);
|
|
||||||
break;
|
|
||||||
case 'error':
|
|
||||||
logText = localBl.errorPrefix + logText.red.bold;
|
|
||||||
break;
|
|
||||||
case 'info':
|
|
||||||
logText = localBl.infoPrefix + clc.xterm(198)(logText);
|
|
||||||
break;
|
|
||||||
case 'normal':
|
|
||||||
logText = localBl.normalPrefix + logText.cyan.bold;
|
|
||||||
break;
|
|
||||||
case 'ok':
|
|
||||||
logText = localBl.okPrefix + logText.bold;
|
|
||||||
break;
|
|
||||||
case 'success':
|
|
||||||
logText = localBl.successPrefix + logText.green.bold;
|
|
||||||
break;
|
|
||||||
case 'warn':
|
|
||||||
logText = localBl.warnPrefix + logText.bold;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
logText.blue.bold;
|
|
||||||
console.log(('unknown logType for "' + logText + '"').red.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;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
/**
|
module.exports = beautylog;
|
||||||
* logs an directory to console
|
|
||||||
* @param logText
|
|
||||||
* @returns {boolean}
|
|
||||||
*/
|
|
||||||
bl.dir = function (logText) {
|
|
||||||
return bl.log(logText, 'dir');
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* logs an error to console
|
|
||||||
* @param logText
|
|
||||||
* @returns {boolean}
|
|
||||||
*/
|
|
||||||
bl.error = function (logText) {
|
|
||||||
return bl.log(logText, 'error');
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* logs an info to console
|
|
||||||
* @param logText
|
|
||||||
* @returns {boolean}
|
|
||||||
*/
|
|
||||||
bl.info = function (logText) {
|
|
||||||
return bl.log(logText, 'info');
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* logs an 'OK!' message to console
|
|
||||||
* @param logText
|
|
||||||
* @returns {boolean}
|
|
||||||
*/
|
|
||||||
bl.ok = function (logText) {
|
|
||||||
return bl.log(logText, 'ok');
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* logs a success to console
|
|
||||||
* @param logText string to log as error
|
|
||||||
* @returns {boolean}
|
|
||||||
*/
|
|
||||||
bl.success = function (logText) {
|
|
||||||
return bl.log(logText, 'success');
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* logs a 'warn:' message to console
|
|
||||||
* @param logText string to log as error
|
|
||||||
* @returns {boolean}
|
|
||||||
*/
|
|
||||||
bl.warn = function (logText) {
|
|
||||||
return bl.log(logText, 'warn');
|
|
||||||
};
|
|
||||||
module.exports = bl;
|
|
||||||
//# sourceMappingURL=index.js.map
|
//# sourceMappingURL=index.js.map
|
@ -1 +1 @@
|
|||||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAC3C,IAAI,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC/B,IAAI,GAAG,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;AAG/B,IAAI,EAAM,CAAC;AACX,EAAE,GAAG,EAAE,CAAA;AAEP;;;GAGG;AACH,IAAI,OAAW,CAAC;AAChB,OAAO,GAAG,EAAE,CAAC;AACb,OAAO,CAAC,SAAS,GAAG,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,GAAG,CAAC;AACnE,OAAO,CAAC,WAAW,GAAG,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,GAAI,GAAG,CAAC;AACzD,OAAO,CAAC,UAAU,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,GAAG,CAAC;AACtE,OAAO,CAAC,YAAY,GAAG,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,GAAI,GAAG,CAAC;AACzD,OAAO,CAAC,QAAQ,GAAG,GAAG,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,GAAI,GAAG,CAAC;AACnE,OAAO,CAAC,aAAa,GAAG,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,GAAI,GAAG,CAAC;AAC/D,OAAO,CAAC,UAAU,GAAG,GAAG,CAAC,QAAQ,GAAG,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,GAAI,GAAG,CAAC;AAEzE;;;;;GAKG;AACH,EAAE,C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2C;AAC3C,wCAAwC;AACxC,6CAA6C;AAE7C,IAAI,SAAS,GAAG,UAAS,WAAyB;IAAzB,2BAAyB,GAAzB,kBAAyB;IAC9C,MAAM,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC;QAClB,KAAK,IAAI;YACL,IAAI,WAAW,GAAG,WAAW,CAAC,IAAI,EAAE,CAAC;YACrC,MAAM,CAAC,WAAW,CAAC;YACnB,KAAK,CAAC;QACV,KAAK,SAAS;YACV,IAAI,gBAAgB,GAAG,gBAAgB,CAAC,IAAI,EAAE,CAAC;YAC/C,MAAM,CAAC,gBAAgB,CAAC;YACxB,KAAK,CAAC;QACV;YACI,OAAO,CAAC,GAAG,CAAC,0DAA0D,CAAC,CAAC;YACxE,KAAK,CAAC;IACd,CAAC;AACL,CAAC,CAAC;AACF,MAAM,CAAC,OAAO,GAAG,SAAS,CAAC"}
|
133
ts/index.ts
133
ts/index.ts
@ -1,121 +1,20 @@
|
|||||||
/// <reference path="./typings/tsd.d.ts" />
|
/// <reference path="./typings/tsd.d.ts" />
|
||||||
var colors = require("colors");
|
/// <reference path="./console.os.ts" />
|
||||||
var clc = require("cli-color");
|
/// <reference path="./console.browser.ts" />
|
||||||
|
|
||||||
|
var beautylog = function(logPlatform:string = "os") {
|
||||||
var bl:any;
|
switch (logPlatform) {
|
||||||
bl = {}
|
case "os":
|
||||||
|
var beautylogOs = BeautylogOS.init();
|
||||||
/**
|
return beautylogOs;
|
||||||
* object to append to all locally used params
|
break;
|
||||||
* @type {{}}
|
case "browser":
|
||||||
*/
|
var beautylogBrowser = BeautylogBrowser.init();
|
||||||
var localBl:any;
|
return beautylogBrowser;
|
||||||
localBl = {};
|
break;
|
||||||
localBl.dirPrefix = clc.bgXterm(39).xterm(231).bold(' DIR ') + ' ';
|
default:
|
||||||
localBl.errorPrefix = ' Error: '.bgRed.white.bold + ' ';
|
console.log("something is strage about the way you required beautylog");
|
||||||
localBl.infoPrefix = clc.bgXterm(198).xterm(231).bold(' INFO ') + ' ';
|
break;
|
||||||
localBl.normalPrefix = ' Log: '.bgCyan.white.bold + ' ';
|
|
||||||
localBl.okPrefix = ' '.bgGreen + ' OK! '.bgBlack.green.bold + ' ';
|
|
||||||
localBl.successPrefix = ' Success: '.bgGreen.white.bold + ' ';
|
|
||||||
localBl.warnPrefix = ' '.bgYellow + ' Warn: '.bgBlack.yellow.bold + ' ';
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param logText
|
|
||||||
* @param logType
|
|
||||||
* @returns {boolean}
|
|
||||||
*/
|
|
||||||
bl.log = (logText:string = 'empty log',logType:string = 'normal') => {
|
|
||||||
try {
|
|
||||||
switch (logType) {
|
|
||||||
case 'dir':
|
|
||||||
logText = localBl.dirPrefix + clc.xterm(26)(logText);
|
|
||||||
break;
|
|
||||||
case 'error':
|
|
||||||
logText = localBl.errorPrefix + logText.red.bold;
|
|
||||||
break;
|
|
||||||
case 'info':
|
|
||||||
logText = localBl.infoPrefix + clc.xterm(198)(logText);
|
|
||||||
break;
|
|
||||||
case 'normal':
|
|
||||||
logText = localBl.normalPrefix + logText.cyan.bold;
|
|
||||||
break;
|
|
||||||
case 'ok':
|
|
||||||
logText = localBl.okPrefix + logText.bold;
|
|
||||||
break;
|
|
||||||
case 'success':
|
|
||||||
logText = localBl.successPrefix + logText.green.bold;
|
|
||||||
break;
|
|
||||||
case 'warn':
|
|
||||||
logText = localBl.warnPrefix + logText.bold;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
logText.blue.bold;
|
|
||||||
console.log(('unknown logType for "' + logText + '"').red.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;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
module.exports = beautylog;
|
||||||
/**
|
|
||||||
* logs an directory to console
|
|
||||||
* @param logText
|
|
||||||
* @returns {boolean}
|
|
||||||
*/
|
|
||||||
bl.dir = function(logText) {
|
|
||||||
return bl.log(logText, 'dir');
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* logs an error to console
|
|
||||||
* @param logText
|
|
||||||
* @returns {boolean}
|
|
||||||
*/
|
|
||||||
bl.error = function(logText) {
|
|
||||||
return bl.log(logText, 'error');
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* logs an info to console
|
|
||||||
* @param logText
|
|
||||||
* @returns {boolean}
|
|
||||||
*/
|
|
||||||
bl.info = function(logText) {
|
|
||||||
return bl.log(logText, 'info');
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* logs an 'OK!' message to console
|
|
||||||
* @param logText
|
|
||||||
* @returns {boolean}
|
|
||||||
*/
|
|
||||||
bl.ok = function(logText) {
|
|
||||||
return bl.log(logText, 'ok');
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* logs a success to console
|
|
||||||
* @param logText string to log as error
|
|
||||||
* @returns {boolean}
|
|
||||||
*/
|
|
||||||
bl.success = function(logText) {
|
|
||||||
return bl.log(logText, 'success');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* logs a 'warn:' message to console
|
|
||||||
* @param logText string to log as error
|
|
||||||
* @returns {boolean}
|
|
||||||
*/
|
|
||||||
bl.warn = function(logText) {
|
|
||||||
return bl.log(logText, 'warn');
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = bl;
|
|
||||||
|
31
ts/test.js
31
ts/test.js
@ -1,24 +1,25 @@
|
|||||||
/// <reference path="./typings/tsd.d.ts" />
|
/// <reference path="./typings/tsd.d.ts" />
|
||||||
var beautyLog = require('./index.js');
|
var beautyLogOs = require('./index.js')("os");
|
||||||
|
var beautyLogBrowser = require("./index.js")("browser");
|
||||||
console.log('*** start test ***');
|
console.log('*** start test ***');
|
||||||
console.log('');
|
console.log('');
|
||||||
console.log('declarative function calls:');
|
console.log('declarative function calls:');
|
||||||
beautyLog.log('beautylog.log(), with normal logText, without logType');
|
beautyLogOs.log('beautylog.log(), with normal logText, without logType');
|
||||||
beautyLog.dir('beautylog.dir(), with normal logText, without logType');
|
beautyLogOs.dir('beautylog.dir(), with normal logText, without logType');
|
||||||
beautyLog.error('beautylog.error(), with normal logText, without logType');
|
beautyLogOs.error('beautylog.error(), with normal logText, without logType');
|
||||||
beautyLog.info('beautylog.dir(), with normal logText, without logType');
|
beautyLogOs.info('beautylog.dir(), with normal logText, without logType');
|
||||||
beautyLog.ok('beautylog.ok(), with normal logText, without logType');
|
beautyLogOs.ok('beautylog.ok(), with normal logText, without logType');
|
||||||
beautyLog.success('beautylog.success(), with normal logText, without logType');
|
beautyLogOs.success('beautylog.success(), with normal logText, without logType');
|
||||||
beautyLog.warn('beautylog.warn(), with normal logText, without logType');
|
beautyLogOs.warn('beautylog.warn(), with normal logText, without logType');
|
||||||
console.log('');
|
console.log('');
|
||||||
console.log('logType String:');
|
console.log('logType String:');
|
||||||
beautyLog.log('beautylog.log(), with normal logText, without logType');
|
beautyLogOs.log('beautylog.log(), with normal logText, without logType');
|
||||||
beautyLog.log('beautylog.log(), with normal logText, with logType "dir"', 'dir');
|
beautyLogOs.log('beautylog.log(), with normal logText, with logType "dir"', 'dir');
|
||||||
beautyLog.log('beautylog.log(), with normal logText, with logType "error"', 'error');
|
beautyLogOs.log('beautylog.log(), with normal logText, with logType "error"', 'error');
|
||||||
beautyLog.log('beautylog.log(), with normal logText, with logType "info"', 'info');
|
beautyLogOs.log('beautylog.log(), with normal logText, with logType "info"', 'info');
|
||||||
beautyLog.log('beautylog.log(), with normal logText, with logType "ok"', 'ok');
|
beautyLogOs.log('beautylog.log(), with normal logText, with logType "ok"', 'ok');
|
||||||
beautyLog.log('beautylog.log(), with normal logText, with logType "success"', 'success');
|
beautyLogOs.log('beautylog.log(), with normal logText, with logType "success"', 'success');
|
||||||
beautyLog.log('beautylog.log(), with normal logText, with logType "warn"', 'warn');
|
beautyLogOs.log('beautylog.log(), with normal logText, with logType "warn"', 'warn');
|
||||||
console.log('');
|
console.log('');
|
||||||
console.log('*** end test ***');
|
console.log('*** end test ***');
|
||||||
//# sourceMappingURL=test.js.map
|
//# sourceMappingURL=test.js.map
|
@ -1 +1 @@
|
|||||||
{"version":3,"file":"test.js","sourceRoot":"","sources":["test.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAC3C,IAAI,SAAS,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;AAEtC,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;AAClC,OAAO,CAAC,GAAG,CAAE,EAAE,CAAC,CAAC;AAEjB,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;AAC3C,SAAS,CAAC,GAAG,CAAC,uDAAuD,CAAC,CAAC;AACvE,SAAS,CAAC,GAAG,CAAC,uDAAuD,CAAC,CAAC;AACvE,SAAS,CAAC,KAAK,CAAC,yDAAyD,CAAC,CAAC;AAC3E,SAAS,CAAC,IAAI,CAAC,uDAAuD,CAAC,CAAC;AACxE,SAAS,CAAC,EAAE,CAAC,sDAAsD,CAAC,CAAC;AACrE,SAAS,CAAC,OAAO,CAAC,2DAA2D,CAAC,CAAC;AAC/E,SAAS,CAAC,IAAI,CAAC,wDAAwD,CAAC,CAAC;AAEzE,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AAEhB,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;AAC/B,SAAS,CAAC,GAAG,CAAC,uDAAuD,CAAC,CAAC;AACvE,SAAS,CAAC,GAAG,CAAC,0DAA0D,EAAC,KAAK,CAAC,CAAC;AAChF,SAAS,CAAC,GAAG,CAAC,4DAA4D,EAAC,OAAO,CAAC,CAAC;AACpF,SAAS,CAAC,GAAG,CAAC,2DAA2D,EAAC,MAAM,CAAC,CAAC;AAClF,SAAS,CAAC,GAAG,CAAC,yDAAyD,EAAC,IAAI,CAAC,CAAC;A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ACtF,WAAW,CAAC,GAAG,CAAC,2DAA2D,EAAC,MAAM,CAAC,CAAC;AACpF,WAAW,CAAC,GAAG,CAAC,yDAAyD,EAAC,IAAI,CAAC,CAAC;AAChF,WAAW,CAAC,GAAG,CAAC,8DAA8D,EAAC,SAAS,CAAC,CAAC;AAC1F,WAAW,CAAC,GAAG,CAAC,2DAA2D,EAAC,MAAM,CAAC,CAAC;AAEpF,OAAO,CAAC,GAAG,CAAE,EAAE,CAAC,CAAC;AACjB,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC"}
|
31
ts/test.ts
31
ts/test.ts
@ -1,28 +1,29 @@
|
|||||||
/// <reference path="./typings/tsd.d.ts" />
|
/// <reference path="./typings/tsd.d.ts" />
|
||||||
var beautyLog = require('./index.js');
|
var beautyLogOs = require('./index.js')("os");
|
||||||
|
var beautyLogBrowser = require("./index.js")("browser");
|
||||||
|
|
||||||
console.log('*** start test ***');
|
console.log('*** start test ***');
|
||||||
console.log ('');
|
console.log ('');
|
||||||
|
|
||||||
console.log('declarative function calls:');
|
console.log('declarative function calls:');
|
||||||
beautyLog.log('beautylog.log(), with normal logText, without logType');
|
beautyLogOs.log('beautylog.log(), with normal logText, without logType');
|
||||||
beautyLog.dir('beautylog.dir(), with normal logText, without logType');
|
beautyLogOs.dir('beautylog.dir(), with normal logText, without logType');
|
||||||
beautyLog.error('beautylog.error(), with normal logText, without logType');
|
beautyLogOs.error('beautylog.error(), with normal logText, without logType');
|
||||||
beautyLog.info('beautylog.dir(), with normal logText, without logType');
|
beautyLogOs.info('beautylog.dir(), with normal logText, without logType');
|
||||||
beautyLog.ok('beautylog.ok(), with normal logText, without logType');
|
beautyLogOs.ok('beautylog.ok(), with normal logText, without logType');
|
||||||
beautyLog.success('beautylog.success(), with normal logText, without logType');
|
beautyLogOs.success('beautylog.success(), with normal logText, without logType');
|
||||||
beautyLog.warn('beautylog.warn(), with normal logText, without logType');
|
beautyLogOs.warn('beautylog.warn(), with normal logText, without logType');
|
||||||
|
|
||||||
console.log('');
|
console.log('');
|
||||||
|
|
||||||
console.log('logType String:');
|
console.log('logType String:');
|
||||||
beautyLog.log('beautylog.log(), with normal logText, without logType');
|
beautyLogOs.log('beautylog.log(), with normal logText, without logType');
|
||||||
beautyLog.log('beautylog.log(), with normal logText, with logType "dir"','dir');
|
beautyLogOs.log('beautylog.log(), with normal logText, with logType "dir"','dir');
|
||||||
beautyLog.log('beautylog.log(), with normal logText, with logType "error"','error');
|
beautyLogOs.log('beautylog.log(), with normal logText, with logType "error"','error');
|
||||||
beautyLog.log('beautylog.log(), with normal logText, with logType "info"','info');
|
beautyLogOs.log('beautylog.log(), with normal logText, with logType "info"','info');
|
||||||
beautyLog.log('beautylog.log(), with normal logText, with logType "ok"','ok');
|
beautyLogOs.log('beautylog.log(), with normal logText, with logType "ok"','ok');
|
||||||
beautyLog.log('beautylog.log(), with normal logText, with logType "success"','success');
|
beautyLogOs.log('beautylog.log(), with normal logText, with logType "success"','success');
|
||||||
beautyLog.log('beautylog.log(), with normal logText, with logType "warn"','warn');
|
beautyLogOs.log('beautylog.log(), with normal logText, with logType "warn"','warn');
|
||||||
|
|
||||||
console.log ('');
|
console.log ('');
|
||||||
console.log('*** end test ***');
|
console.log('*** end test ***');
|
Loading…
Reference in New Issue
Block a user