108 lines
9.4 KiB
JavaScript
108 lines
9.4 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
const plugins = require("./beautylog.plugins");
|
|
/**
|
|
*
|
|
* @param logText
|
|
* @param logType
|
|
* @returns {boolean}
|
|
*/
|
|
exports.internalLog = function (logType = 'normal', logText = 'empty log') {
|
|
switch ((new plugins.smartenv.Smartenv()).runtimeEnv) {
|
|
case 'node':
|
|
exports.logNode(logType, logText);
|
|
break;
|
|
case 'browser':
|
|
logBrowser(logText, logType);
|
|
break;
|
|
default:
|
|
console.log('something is strange about the platform in which you try to use beautylog');
|
|
break;
|
|
}
|
|
};
|
|
let coloredString = plugins.beautycolor.coloredString;
|
|
let localBl = {
|
|
dirPrefix: coloredString(' DIR ', 'white', 'blue') + ' ',
|
|
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') + ' ',
|
|
okPrefix: coloredString(' ', 'green', 'green') + coloredString(' OK! ', 'green', 'black') + ' ',
|
|
successPrefix: coloredString(' ', 'green', 'green') + coloredString(' SUCCESS! ', 'green', 'black') + ' ',
|
|
warnPrefix: coloredString(' ', 'orange', 'orange') + coloredString(' WARN: -> ', 'orange', 'black') + ' '
|
|
};
|
|
exports.logNode = function (logType, logText) {
|
|
try {
|
|
switch (logType) {
|
|
case 'dir':
|
|
logText = localBl.dirPrefix + coloredString(logText, 'blue');
|
|
break;
|
|
case 'error':
|
|
logText = localBl.errorPrefix + coloredString(logText, 'red');
|
|
break;
|
|
case 'info':
|
|
logText = localBl.infoPrefix + coloredString(logText, 'blue');
|
|
break;
|
|
case 'normal':
|
|
logText = localBl.logPrefix + coloredString(logText, 'cyan');
|
|
break;
|
|
case 'note':
|
|
logText = localBl.notePrefix + coloredString(logText, 'pink');
|
|
break;
|
|
case 'ok':
|
|
logText = localBl.okPrefix + coloredString(logText, 'green');
|
|
break;
|
|
case 'success':
|
|
logText = localBl.successPrefix + coloredString(logText, 'green');
|
|
break;
|
|
case 'warn':
|
|
logText = localBl.warnPrefix + coloredString(logText, 'orange');
|
|
break;
|
|
case 'log':
|
|
logText = localBl.logPrefix + coloredString(logText, 'cyan');
|
|
break;
|
|
default:
|
|
coloredString(logText, 'blue');
|
|
console.log('unknown logType for "' + logText + '"');
|
|
break;
|
|
}
|
|
console.log(logText);
|
|
return true;
|
|
}
|
|
catch (error) {
|
|
console.log(localBl.errorPrefix + 'You seem to have tried logging something strange' + error);
|
|
return false;
|
|
}
|
|
};
|
|
let logBrowser = function (logText, logType) {
|
|
switch (logType) {
|
|
case 'dir':
|
|
logText = localBl.dirPrefix + coloredString(logText, 'blue');
|
|
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':
|
|
logText = localBl.logPrefix + logText.cyan.bold;
|
|
break;
|
|
case 'ok':
|
|
console.log('%c OK: %c ' + logText, 'background:#000000;color:#8BC34A;', 'color:#000000;');
|
|
break;
|
|
case 'success':
|
|
console.log('%c Success: %c ' + logText, 'background:#8BC34A;color:#ffffff;', 'color:#8BC34A;');
|
|
break;
|
|
case 'warn':
|
|
console.log('%c Warn: %c ' + logText, 'background:#000000;color:#FB8C00;', 'color:#000000;');
|
|
break;
|
|
case 'log':
|
|
console.log('%c Log: %c ' + logText, 'background:#42A5F5;color:#ffffff', 'color:#42A5F5;');
|
|
break;
|
|
default:
|
|
console.log('unknown logType for "' + logText + '"');
|
|
break;
|
|
}
|
|
};
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2Z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