2016-05-02 00:23:40 +00:00
|
|
|
"use strict";
|
2016-07-23 17:47:23 +00:00
|
|
|
const plugins = require("./beautylog.plugins");
|
2016-07-23 23:17:38 +00:00
|
|
|
const beautylog_remote_1 = require("./beautylog.remote");
|
2016-05-02 00:23:40 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param logText
|
|
|
|
* @param logType
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
2016-07-23 23:17:38 +00:00
|
|
|
exports.internalLog = function (logType = 'normal', logText = 'empty log') {
|
2016-05-02 00:23:40 +00:00
|
|
|
switch (plugins.smartenv.getEnv().runtimeEnv) {
|
2016-10-16 00:26:43 +00:00
|
|
|
case 'node':
|
2016-07-23 23:17:38 +00:00
|
|
|
exports.logNode(logType, logText);
|
|
|
|
beautylog_remote_1.remoteLog(logType, logText);
|
2016-05-02 00:23:40 +00:00
|
|
|
break;
|
2016-10-16 00:26:43 +00:00
|
|
|
case 'browser':
|
2016-05-02 00:23:40 +00:00
|
|
|
logBrowser(logText, logType);
|
|
|
|
break;
|
|
|
|
default:
|
2016-10-16 00:26:43 +00:00
|
|
|
console.log('something is strange about the platform in which you try to use beautylog');
|
2016-05-02 00:23:40 +00:00
|
|
|
break;
|
|
|
|
}
|
2016-10-16 00:26:43 +00:00
|
|
|
};
|
2017-01-21 17:40:40 +00:00
|
|
|
let coloredString = plugins.beautycolor.coloredString;
|
2016-07-23 23:17:38 +00:00
|
|
|
let localBl = {
|
2017-01-21 17:40:40 +00:00
|
|
|
dirPrefix: coloredString(' DIR ', 'white', 'blue') + ' ',
|
2017-01-21 22:12:39 +00:00
|
|
|
errorPrefix: coloredString(' ', 'red', 'red') + coloredString(' ERROR! ', 'red', 'black') + ' ',
|
|
|
|
infoPrefix: coloredString(' ', 'blue', 'blue') + coloredString(' INFO: ', 'blue', 'black') + ' ',
|
|
|
|
logPrefix: coloredString(' ', 'white', 'cyan') + coloredString(' LOG: ', 'cyan', 'black') + ' ',
|
|
|
|
notePrefix: coloredString(' ', 'pink', 'pink') + coloredString(' NOTE -> ', 'pink', 'black') + ' ',
|
2017-01-21 17:40:40 +00:00
|
|
|
okPrefix: coloredString(' ', 'green', 'green') + coloredString(' OK! ', 'green', 'black') + ' ',
|
2017-01-21 22:12:39 +00:00
|
|
|
successPrefix: coloredString(' ', 'green', 'green') + coloredString(' SUCCESS! ', 'green', 'black') + ' ',
|
|
|
|
warnPrefix: coloredString(' ', 'orange', 'orange') + coloredString(' WARN: -> ', 'orange', 'black') + ' '
|
2016-05-02 00:23:40 +00:00
|
|
|
};
|
2016-07-23 23:17:38 +00:00
|
|
|
exports.logNode = function (logType, logText) {
|
2016-05-02 00:23:40 +00:00
|
|
|
try {
|
|
|
|
switch (logType) {
|
|
|
|
case 'dir':
|
2017-01-21 17:40:40 +00:00
|
|
|
logText = localBl.dirPrefix + coloredString(logText, 'blue');
|
2016-05-02 00:23:40 +00:00
|
|
|
break;
|
|
|
|
case 'error':
|
2017-01-21 17:40:40 +00:00
|
|
|
logText = localBl.errorPrefix + coloredString(logText, 'red');
|
2016-05-02 00:23:40 +00:00
|
|
|
break;
|
|
|
|
case 'info':
|
2017-01-21 20:11:41 +00:00
|
|
|
logText = localBl.infoPrefix + coloredString(logText, 'blue');
|
2016-05-02 00:23:40 +00:00
|
|
|
break;
|
|
|
|
case 'normal':
|
2017-01-21 17:40:40 +00:00
|
|
|
logText = localBl.logPrefix + coloredString(logText, 'cyan');
|
2016-05-02 00:23:40 +00:00
|
|
|
break;
|
2017-01-21 22:12:39 +00:00
|
|
|
case 'note':
|
|
|
|
logText = localBl.notePrefix + coloredString(logText, 'pink');
|
|
|
|
break;
|
2016-05-02 00:23:40 +00:00
|
|
|
case 'ok':
|
2017-01-21 18:52:31 +00:00
|
|
|
logText = localBl.okPrefix + coloredString(logText, 'green');
|
2016-05-02 00:23:40 +00:00
|
|
|
break;
|
|
|
|
case 'success':
|
2017-01-21 17:40:40 +00:00
|
|
|
logText = localBl.successPrefix + coloredString(logText, 'green');
|
2016-05-02 00:23:40 +00:00
|
|
|
break;
|
|
|
|
case 'warn':
|
2017-01-21 17:40:40 +00:00
|
|
|
logText = localBl.warnPrefix + coloredString(logText, 'orange');
|
2016-05-02 00:23:40 +00:00
|
|
|
break;
|
|
|
|
case 'log':
|
2017-01-21 17:40:40 +00:00
|
|
|
logText = localBl.logPrefix + coloredString(logText, 'cyan');
|
2016-05-02 00:23:40 +00:00
|
|
|
break;
|
|
|
|
default:
|
2017-01-21 17:40:40 +00:00
|
|
|
coloredString(logText, 'blue');
|
2016-10-16 00:26:43 +00:00
|
|
|
console.log(('unknown logType for "' + logText + '"'));
|
2016-05-02 00:23:40 +00:00
|
|
|
break;
|
|
|
|
}
|
2017-01-21 22:12:39 +00:00
|
|
|
console.log(logText);
|
2016-05-02 00:23:40 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
catch (error) {
|
2016-10-16 00:26:43 +00:00
|
|
|
console.log(localBl.errorPrefix
|
|
|
|
+ 'You seem to have tried logging something strange' + error);
|
2016-05-02 00:23:40 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|
2016-07-23 17:47:23 +00:00
|
|
|
let logBrowser = function (logText, logType) {
|
2016-05-02 00:23:40 +00:00
|
|
|
switch (logType) {
|
|
|
|
case 'dir':
|
2017-01-21 17:40:40 +00:00
|
|
|
logText = localBl.dirPrefix + coloredString(logText, 'blue');
|
2016-05-02 00:23:40 +00:00
|
|
|
break;
|
|
|
|
case 'error':
|
|
|
|
logText = localBl.errorPrefix + logText.red.bold;
|
|
|
|
break;
|
|
|
|
case 'info':
|
|
|
|
console.log('%c Info: %c ' + logText, 'background:#EC407A;color:#ffffff;', 'color:#EC407A;');
|
|
|
|
break;
|
|
|
|
case 'normal':
|
2016-10-16 00:26:43 +00:00
|
|
|
logText = localBl.logPrefix + logText.cyan.bold;
|
2016-05-02 00:23:40 +00:00
|
|
|
break;
|
|
|
|
case 'ok':
|
2016-10-16 00:26:43 +00:00
|
|
|
console.log('%c OK: %c ' + logText, 'background:#000000;color:#8BC34A;', 'color:#000000;');
|
2016-05-02 00:23:40 +00:00
|
|
|
break;
|
|
|
|
case 'success':
|
2016-10-16 00:26:43 +00:00
|
|
|
console.log('%c Success: %c ' + logText, 'background:#8BC34A;color:#ffffff;', 'color:#8BC34A;');
|
2016-05-02 00:23:40 +00:00
|
|
|
break;
|
|
|
|
case 'warn':
|
2016-10-16 00:26:43 +00:00
|
|
|
console.log('%c Warn: %c ' + logText, 'background:#000000;color:#FB8C00;', 'color:#000000;');
|
2016-05-02 00:23:40 +00:00
|
|
|
break;
|
|
|
|
case 'log':
|
2016-10-16 00:26:43 +00:00
|
|
|
console.log('%c Log: %c ' + logText, 'background:#42A5F5;color:#ffffff', 'color:#42A5F5;');
|
2016-05-02 00:23:40 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
console.log('unknown logType for "' + logText + '"');
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
};
|
2017-01-21 22:12:39 +00:00
|
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmVhdXR5bG9nLmxvZy5oZWxwZXJzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvYmVhdXR5bG9nLmxvZy5oZWxwZXJzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSwrQ0FBOEM7QUFDOUMseURBQThDO0FBRTlDOzs7OztHQUtHO0FBQ1EsUUFBQSxXQUFXLEdBQUcsVUFBVSxVQUFrQixRQUFRLEVBQUUsVUFBa0IsV0FBVztJQUN4RixNQUFNLENBQUMsQ0FBQyxPQUFPLENBQUMsUUFBUSxDQUFDLE1BQU0sRUFBRSxDQUFDLFVBQVUsQ0FBQyxDQUFDLENBQUM7UUFDM0MsS0FBSyxNQUFNO1lBQ1AsZUFBTyxDQUFDLE9BQU8sRUFBRSxPQUFPLENBQUMsQ0FBQTtZQUN6Qiw0QkFBUyxDQU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