56 lines
4.1 KiB
JavaScript
56 lines
4.1 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
class BeautyBrowser {
|
|
constructor() {
|
|
/**
|
|
* parse logs for display
|
|
*/
|
|
this.parseLog = (stringToParseArg) => {
|
|
const parseLogRegex = /^(success|ok|info|warn|error):\s(.*)/;
|
|
const regexResult = parseLogRegex.exec(stringToParseArg);
|
|
if (regexResult.length === 3) {
|
|
return {
|
|
logType: regexResult[1],
|
|
logString: regexResult[2]
|
|
};
|
|
}
|
|
else {
|
|
return {
|
|
logType: 'log',
|
|
logString: stringToParseArg
|
|
};
|
|
}
|
|
};
|
|
}
|
|
handleLog(logPackage) {
|
|
this.logInBrowser(this.parseLog(logPackage.message));
|
|
}
|
|
logInBrowser(beautyLogObjectArg) {
|
|
const { logType, logString } = beautyLogObjectArg;
|
|
switch (logType) {
|
|
case 'error':
|
|
console.log('%c Error: %c ' + logString, 'background:#000000;color:#800000;', 'color:#000000;');
|
|
break;
|
|
case 'info':
|
|
console.log('%c Info: %c ' + logString, 'background:#EC407A;color:#ffffff;', 'color:#EC407A;');
|
|
break;
|
|
case 'ok':
|
|
console.log('%c OK: %c ' + logString, 'background:#000000;color:#8BC34A;', 'color:#000000;');
|
|
break;
|
|
case 'success':
|
|
console.log('%c Success: %c ' + logString, 'background:#8BC34A;color:#ffffff;', 'color:#8BC34A;');
|
|
break;
|
|
case 'warn':
|
|
console.log('%c Warn: %c ' + logString, 'background:#000000;color:#FB8C00;', 'color:#000000;');
|
|
break;
|
|
case 'log':
|
|
console.log('%c Log: %c ' + logString, 'background:#42A5F5;color:#ffffff', 'color:#42A5F5;');
|
|
break;
|
|
default:
|
|
console.log('unknown logType for "' + logString + '"');
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
exports.BeautyBrowser = BeautyBrowser;
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290I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