stellar-plus
Version:
beta version of stellar-plus, an all-in-one sdk for the Stellar blockchain
39 lines (38 loc) • 1.39 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.DebugPlugin = void 0;
const tslib_1 = require("tslib");
const types_1 = require("../../../../../../stellar-plus/utils/pipeline/conveyor-belts/types");
class DebugPlugin {
constructor(debugLevel = 'error') {
this.name = 'DebugPlugin';
this.log = (level, message) => {
if (this.debugLevel === 'all' || this.debugLevel === level) {
console.log(message);
}
};
this.type = types_1.GenericPlugin.id;
this.debugLevel = debugLevel;
}
preProcess(item, meta) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
this.log('info', `>> Start ${meta.beltType}`);
this.log('all', ` Belt:${meta.beltId} \n Item:${meta.itemId}`);
return item;
});
}
postProcess(item, meta) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
this.log('info', `<< Finish ${meta.beltType}`);
this.log('all', ` Belt:${meta.beltId} \n Item:${meta.itemId}`);
return item;
});
}
processError(error, _meta) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
this.log('error', `Error: ${error}`);
return error;
});
}
}
exports.DebugPlugin = DebugPlugin;