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 && 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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2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