skyflow-node
Version:
Skyflow SDK for Node.js
61 lines • 2.28 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getElementName = exports.parameterizedString = exports.printLog = exports.EnvOptions = exports.LogLevelOptions = void 0;
const Logging_1 = require("../../Logging");
const common_1 = require("../common");
exports.LogLevelOptions = {
DEBUG: {
showDebugLogs: true, showInfoLogs: true, showWarnLogs: true, showErrorLogs: true,
},
INFO: {
showDebugLogs: false, showInfoLogs: true, showWarnLogs: true, showErrorLogs: true,
},
WARN: {
showDebugLogs: false, showInfoLogs: false, showWarnLogs: true, showErrorLogs: true,
},
ERROR: {
showDebugLogs: false, showInfoLogs: false, showWarnLogs: false, showErrorLogs: true,
},
OFF: {
showDebugLogs: false, showInfoLogs: false, showWarnLogs: false, showErrorLogs: false,
}
};
exports.EnvOptions = {
PROD: {
doesReturnValue: false,
},
DEV: {
doesReturnValue: true,
},
};
const printLog = (message, messageType) => {
const logLevel = (0, Logging_1.getLogLevel)();
const { showDebugLogs, showInfoLogs, showWarnLogs, showErrorLogs, } = exports.LogLevelOptions[logLevel];
if (messageType === common_1.MessageType.LOG && showDebugLogs) {
console.log("DEBUG: [Skyflow] " + message);
}
else if (messageType === common_1.MessageType.LOG && showInfoLogs) {
console.log("INFO: [Skyflow] " + message);
}
else if (messageType === common_1.MessageType.WARN && showWarnLogs) {
console.warn("WARN: [Skyflow] " + message);
}
else if (messageType === common_1.MessageType.ERROR && showErrorLogs) {
console.error("ERROR: [Skyflow] " + message);
}
};
exports.printLog = printLog;
const parameterizedString = (...args) => {
const str = args[0];
const params = args.filter((arg, index) => index !== 0);
if (!str)
return '';
return str.replace(/%s[0-9]+/g, (matchedStr) => {
const variableIndex = matchedStr.replace('%s', '') - 1;
return params[variableIndex];
});
};
exports.parameterizedString = parameterizedString;
const getElementName = (name) => atob(name.split(':')[2]);
exports.getElementName = getElementName;
//# sourceMappingURL=index.js.map